Powershell Active Directory Properties

I am trying to find the properties of the 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 do not know what other properties I have available.

How can I find which properties I can get from $ objitem?

edit:

This solution is used using the answers below:

foreach ($objResult in $colResults){   
   ($colResults)[0].Properties.PropertyNames
}
+1
source share
3 answers
foreach ($ objResult in $ colResults) {   
    $ objResult.Properties | % {$ _. propertynames}
}

must display the keys of each property of the result.

+3
source

Use the cmdlet get-member(alias as gm) to get all properties and methods. In this way,

$objItem | gm

, format-list (aliased as fl), . ,

$objItem | fl *

0

Well, the previous answers are Powershell functions. If you really want to know what attributes you can get for this class (here the user is clas), you need to take a look at the diagram. which is available on a Windows server by registering the schmmgmt.dll COM object.

C:\>regsvr32 c:\WINDOWS\system32\schmmgmt.dll

In JP

0
source

All Articles