Add "$searcher.PropertiesToLoad = 'CustomReboot'".
PowerShell makes life easy, but if you're dealing with .Net you have to do the work. ;-)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Greetings,
I am using the directorysearcher to retrieve the value of a custom AD attribute.
I am at a loss to explain this behaviour when I try to retrieve it.
I first run this code:
$searcher = New-Object DirectoryServices.DirectorySearcher
$searcher.Filter = "(&(name=Computer1)(objectClass=computer))"
$searcher.pageSize = 1000
$ADSearchResults = $searcher.FindAll()
I then try to display the custom attribute by running this command:
$ADSearchResults.Properties.CustomReboot
...and nothing is displayed.
If I type this:
$ADSearchResults.Properties.CustomReboot[0]
...then the value is returned - however if I type this:
$ADSearchResults.Properties
...all the properties are returned - now here's the thing - if I now type this:
$ADSearchResults.Properties.CustomReboot
It returns a value where it didnt when I first typed it after the findall command.
Why is this happening?
Thanks
David Z
Add "$searcher.PropertiesToLoad = 'CustomReboot'".
PowerShell makes life easy, but if you're dealing with .Net you have to do the work. ;-)
Now the behaviour is getting weirder.
I tried retrieving the value for computer A and
$ADSearchResults.Properties.CustomReboot[0] didnt work where
$ADSearchResults.Properties.CustomReboot did.
but for computer B
$ADSearchResults.Properties.CustomReboot didnt work where
$ADSearchResults.Properties.CustomReboot[0] did.