I am trying to find the properties of active directory:
$strFilter = "(&(objectCategory=User))"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults){
$objItem = $objResult.Properties
I can call $objitem.name, but I don't know which other properties I have accessible.
How can I find which properties I can access from $objitem?
edit:
Used this solution using the answers below:
foreach ($objResult in $colResults){
($colResults)[0].Properties.PropertyNames
}
Ok, preceding answers are "Powershell" features. If you really want to know what are the attributes you can reach for a given class (clas user here) you have to have a look to the Schema. which is avaible on Windows server registering the schmmgmt.dll COM object.
JP
should display the keys of each result property.
Use the
get-member
(aliased asgm
) cmdlet to get all the properties and methods. Like so,$objItem | gm
Another a way is to pipe the object to
format-list
(aliased asfl
) cmdlet, which won't list methods. Like so,$objItem | fl *