$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
24 Jun // php the_time('Y') ?>
I wanted to read the otherWellKnownObjects attribute from an Active Directory object.
In my case this was the Microsoft Exchange container in the Configuration partition:
The otherWellKnownObjects attribute is of type ADSTYPE_DN_WITH_BINARY which unfortunately cannot be viewed or edited with ADSI Edit:
So I wrote a script to read the values with PowerShell but it’s not very straightforward how to do this.
Reading the otherWellKnownObjects property returns a collection of IADsDNWithBinary interfaces but this interface is unknown in PowerShell.
Using reflection we can read the values:
1 2 3 4 5 6 7 8 9 10 11 12 | $objCN = New-Object System.DirectoryServices.DirectoryEntry("LDAP://CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=zorg,DC=local") $gp = [Reflection.Bindingflags]::GetProperty foreach ($objWKO in $objCN.otherWellKnownObjects) { $objType = $objWKO.GetType() $DNString = $objType.InvokeMember("DNString", $gp, $null, $objWKO, $null) $BV = $objType.InvokeMember("BinaryValue", $gp, $null, $objWKO, $null) $Guid = [GUID][System.BitConverter]::ToString($BV).Replace("-", "") Write-Host "DNString=$DNString" -foregroundcolor Blue Write-Host "Guid=$Guid" -foregroundcolor Blue } |
One Response for "Reading the otherWellKnownObjects attribute with PowerShell"
[…] script.First I read the the otherWellKnownObjects attribute with PowerShell (I wrote about that earlier).This returns a Collection that I walk backwards with a for loop, this is important when removing […]
Leave a reply