ryan
ryan

Reputation: 13

How to view all properties of an AD User object?

I recently started playing around with power shell and just finished reading the learn PowerShell in a month of lunches book.

I'm playing around with the Get-AdUser cmdlet and I'm confused about all the AD users properties. for example:

Get-ADUser -filter {name -like "ryan*"} | Format-Table *

It's my understanding that | Format-Table * or | get-member should return all properties of an object. However I came across this command:

Get-ADUser -filter {name -like "ryan*"}  –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed"

That adds a DisplayName and msDS-UserPasswordExpiryTimeComputed properties to the objects.

My question is why weren't these properties listed under get-member? Is there a way I can view all the properties of get-aduser?

Upvotes: 1

Views: 23936

Answers (1)

Matt
Matt

Reputation: 46700

[W]hy weren't these properties listed under get-member?

Get-Member will show you all the members, properties etc. of the object requested. It is doing exactly what you asked of it1.

Get-Aduser has a default property set it gets from AD e.g. DisplayName, samaccountname and etc. If you want more then you need to ask for more. From TechNet for Get-Aduser

Properties

Specifies the properties of the output object to retrieve from the server. Use this parameter to retrieve properties that are not included in the default set.

Specify properties for this parameter as a comma-separated list of names. To display all of the attributes that are set on the object, specify * (asterisk).

So if you use -Properties * you will get all of that AD objects properties. Understand that -Properties *, while simple to use, is a performance hog as it queries for non-indexed attributes. If you can, reduce your selection set to just the ones you actually need.


1. There are some hidden properties of PowerShell objects that -Force exposes but that is not what you are asking about.

Upvotes: 2

Related Questions