Learning something new every day. There was a question in the forums on PowerGUI.org today on obtaining a list of all attributes a user object has.
I used to think that the way to get the list of attributes exposed directly via PowerShell is to call:
PS:\> Get-QADUser | Get-Member
Or use a user as an example:
PS:\> Get-QADUser "Dmitry Sotnikov" | Format-List
And if you want to get to the more advanced AD properties (such as for example Msds-ResultantPSo
in this example of managing fine-grained password policies) you are screwed and have to go to MSDN and read the AD schema docs.
As it turns out, this is not the case! You can get the full list of attributes available for a user object with this one call:
PS C:\> Get-QADUser -ReturnPropertyNamesOnly -IncludeAllProperties
objectClass
cn
instanceType
nTSecurityDescriptor
objectCategory
objectSid
sAMAccountName
...
Thanks to Rostislav for the tip!
In my network this gave 458 attributes so I am not providing the full output here.
Tags: oneliner, AD cmdlets, cmdlets, one-liner, PowerShell, AD, Active Directory, Examples
UPDATE: Changed Format-Table
to Format-List
. Format-Table
with no property names specified after it is more or less useless – it just gives the default output. Format-List by default lists all properties exposed directly via PowerShell with their values.