Reputation: 1453
So I have a list of Active Directory users:
$users = Get-AdUser -Filter {Enabled -eq "True"}
What I want to do is group them based on their description since you have 3 possible descriptions in the whole user list.
However: I can't even seem to even use the Description
field inside of a foreach
:
foreach ($user in $users)
{
Write-Host $user.Name
Write-Host $user.Description
}
Their name shows but not their description.
Why is this?
Upvotes: 2
Views: 360
Reputation: 23355
Get-ADUser
only returns specific properties by default. The description property is not one of these. To ensure it is returned you need to use the following parameter with Get-ADUser
:
-Properties Description
"This cmdlet retrieves a default set of user object properties. To retrieve additional properties use the Properties parameter." - https://technet.microsoft.com/en-gb/library/ee617241.aspx
Upvotes: 4