Powershell active directory properties

2019-08-06 03:58发布

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
}

3条回答
Viruses.
2楼-- · 2019-08-06 04:42

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

查看更多
beautiful°
3楼-- · 2019-08-06 04:55
foreach ($objResult in $colResults){   
    $objResult.Properties | % {$_.propertynames}
}

should display the keys of each result property.

查看更多
淡お忘
4楼-- · 2019-08-06 04:58

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 *

查看更多
登录 后发表回答