Use a field of a variable inside of a foreach in PowerShell -
so have list of active directory users:
$users = get-aduser -filter {enabled -eq "true"}
what want group them based on description since have 3 possible descriptions in whole user list.
however: can't seem use description
field inside of foreach
:
foreach ($user in $users) { write-host $user.name write-host $user.description }
their name shows not description.
why this?
get-aduser
returns specific properties default. description property not 1 of these. ensure returned need use following parameter get-aduser
:
-properties description
"this cmdlet retrieves default set of user object properties. retrieve additional properties use properties parameter." - https://technet.microsoft.com/en-gb/library/ee617241.aspx
Comments
Post a Comment