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 descriptionfield 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

Popular posts from this blog

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -