Reputation: 13
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
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
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