catmanavan
catmanavan

Reputation: 13

Get-ADUser -properties: only want to show one attribute

I'm trying to pull one attribute from a user. However, the -properties parameter pulls in the default parameters plus the one I'm looking for. Is there a way to prevent the default values from showing up?

Line looks like this:

Get-ADUser -identity "name" -properties "attributename"

Upvotes: 1

Views: 5245

Answers (2)

Mike L'Angelo
Mike L'Angelo

Reputation: 880

Use

$myAttr = (Get-ADUser -identity "name" -properties attributename).attributename

Select-Object cmdlet creates new custom objects that contain properties selected from the object. As such, their type Is NoteProperty.

References here:https://blogs.msdn.microsoft.com/vishinde/2012/08/27/expandproperty-in-select-object/

Upvotes: 1

HAL9256
HAL9256

Reputation: 13483

No matter what, you will always get the default properties if you keep it as an ADUser object. If you want to only show one property, then the easiest is to pipe it through a Select statement which will filter out every thing else and only return the property you want:

Get-ADUser -identity "name" -properties "attributename" | Select "attributename"

Upvotes: 1

Related Questions