active directory - Powershell: import-csv and get-aduser -
i trying find users, storing in 'users.csv' in ad:
import-module activedirectory import-csv "\users.csv" | foreach-object { get-aduser -filter {displayname -eq $_.id}}
but ps says 'id' property not found
users.csv contents:
id macaskill danny cedric gracia
e.t.c
edit csv file , enclose displaynames double quotes so,
id "macaskill danny" "cedric gracia"
after that, use itermediate variable so,
import-csv .\users.csv | % { $f = $_.id; # set displayname temp variable get-aduser -filter { displayname -eq $f } # use temp variable filter }
i don't konw why intermeidate variable needed. there weird going on passing , parsing variables -filter
parameter.
Comments
Post a Comment