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
}
foreach ($objResult in $colResults){ $objResult.Properties | % {$_.propertynames} }
should display the keys of each result property.
Use the get-member
(aliased as gm
) cmdlet to get all the properties and methods. Like so,
$objItem | gm
Another a way is to pipe the object to format-list
(aliased as fl
) cmdlet, which won't list methods. Like so,
$objItem | fl *
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.
C:\>regsvr32 c:\WINDOWS\system32\schmmgmt.dll
JP
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.