Monday 8 October 2018

Powershell: All Properties of an Object in Active Directory

Sometimes you need to see all the properties of an object in Powershell.


When we type:

Get-ADObject -Filter 'Name -like "guest"' | fl

You get these properties in the response:








To get ALL the properties of  the object, TYPE:

Get-ADObject -Filter 'Name -like "guest"' -Properties *

Then you get the response:





Now we can choose any property we want to work with from the list.
Get-ADObject -Filter 'Name -like "guest"' -Properties whenCreated

This gets us:


Well, we got the property we wanted, but we got more than we wanted, getting some of the default properties as well.



To only get the property we want we need to type:

Get-ADObject -Filter 'Name -like "guest"' -Properties * | FT -Property whenCreated

Finally we are getting close with the date (in this case) below the property:



Now annoyingly we get a menu this time, with the object property name above the value.

To isolate the value, type:

Get-ADObject -Filter 'Name -like "guest"' -Properties * | Select-Object -ExpandProperty whenCreated



And off we go. Hopefully this helped you out.






No comments:

Post a Comment