Public/Get-SpecPrinterPermission.ps1
Function Get-SpecPrinterPermission { <# .SYNOPSIS This function retrieves the security descriptor definition language (SDDL) permissions of a specified printer. .DESCRIPTION The Get-SpecPrinterPermission function retrieves the SDDL permissions of a specific printer. It utilizes the Get-Printer cmdlet to obtain detailed information about the printer, including its PermissionSDDL property. .PARAMETER Printer The name of the printer for which you want to retrieve permissions. .EXAMPLE Get-SpecPrinterPermission -Printer "Printer1" This example retrieves the SDDL permissions of the printer named "Printer1". .NOTES Author: andy.naftel Version: 1.0 Original Code 1.1 - [owen.heaume] Add comment-based help - [owen.heaume] Added error handling and return codes 1.2 - [owen.heaume] Refactor to remove redundant code .LINK Add-SpecPrinterPermission #> [cmdletbinding()] param ( [Parameter(Mandatory = $True)] $Printer ) Write-Verbose "Retrieving current printer SDDL permissions for $Printer" try { $OriginalSDDL = Get-Printer -Full -Name $Printer | Select-Object PermissionSDDL -ExpandProperty PermissionSDDL Return $OriginalSDDL } catch { Write-Warning "Unable to retrieve current printer SDDL permissions for $Printer" Return 101 } } |