I wanted to take the SID and identify the user or group account that was associated with it. After a quick search I found a few examples that looked similar to this:
$objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-21-1454471165-1004335555-1606985555-5555")
$objUser = $objSID.Translate([System.Security.Principal.NTAccount])
$objUser.Value
Above example taken from: https://technet.microsoft.com/en-us/library/ff730940.aspx
It seemed to me that there had to be an easier way using the ActiveDirectory module for PowerShell which isn't used by these examples. Good news, there is!
You can't use Get-ADUser or Get-ADGroup to identify the SID name because it could be either one. However, you can use Get-ADObject:
Get-ADObject -Filter {objectSID -eq "
S-1-5-21-1454471165-1004335555-1606985555-5555
"}
If the command does not return any results then there is no AD object with that SID.
No comments:
Post a Comment