Print SID on all users in Active Directory
This little snippet was actually my first try at Powershell. Since I have experience from Perl, C# and Bash I hoped that the learning curve shouldn't be so steep and I was amazed at how easy the transition from Perl/C#(.NET) was.
However, I haven't yet grasped the Powershell output functions, so this script does an ugly string.Format to output the data...
foreach ($res in (New-Object System.DirectoryServices.DirectorySearcher -argument "(objectClass=user)").FindAll()) { $user = $res.GetDirectoryEntry() [string]::Format("{0}:{1}",$user.Name.ToString(),(New-Object System.Security.Principal.SecurityIdentifier -argument $user.objectSid[0],0).ToString())}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home