Convert-SidToADObject will take an AD SID and return an object containing the object’s name, SamAccountName, Description, type and distinguished name. function Convert-SidToADObject($sid) { $u = [adsi](“LDAP://<SID=” + $sid + “>”) if ($u.SamAccountName) { [psCustomObject]@{ Name = $u.Name.value SamAccountName = $u.samAccountName.value Description = $u.description.value Type = $u.objectclass.Value[1] DistinguishedName = $u.distinguishedName.value } } Else { “Lookup Failed”…
Tag: ADSI
Convert System.DirectoryServices.SearchResult to a PSObject
The ADSI accelerator is fast, and built into PowerShell, unlike the Active Directory Module. When use it, or the ADSISearcher, you have results which look like this [Image from previous Microsoft URL]: Getting the properties out to a file can be tricky. I wrote two little functions to make this easier: Function ConvertTo-PSObjectFromDirectorySearchResult($oDS){ $outval =…