Reputation: 117
I have a script to get permissions from printers on my printer server, but the output is returning SIDs, is there something that I can pipe in to get the user names as the output? I'll be doing this for multiple printers at a time so running each SID through a script to convert them is overly time consuming. Below is my script.
(Get-Printer 'brem-pt-8106H' -Full).PermissionSDDL
Upvotes: 0
Views: 1359
Reputation: 19664
Assumption: user exists in the domain
#Requires -Version 5
$SID = [System.Security.Principal.SecurityIdentifier]::new(
(Get-Printer 'brem-pt-8106H' -Full).PermissionSDDL
)
$User = ($SID.Translate([System.Security.Principal.NTAccount])).Value
Cleaned up as a function you can pipe to:
Function Get-UsernameFromSddl
{
[CmdletBinding()]
[OutputType([String])]
Param(
[Parameter(Mandatory,ValueFromPipeline,Position=0)]
[String]$Sddl
)
$Sid = New-Object -TypeName 'System.Security.Principal.SecurityIdentifier' -ArgumentList $Sddl
$User = $Sid.Translate([System.Security.Principal.NTAccount])
Return $User.Value
}
Upvotes: 1