I have CSV file:
phone username
-------- ---------
1 user1
2 user2
first I run:
$arr = import-csv "c:\names.csv"
so for example this is the output when I run:
$arr[0].username
user1
Now, my goal is to find this user in AD and when I run:
$user = get-aduser -filter {Name -eq $arr[0].username}
I received:
Get-ADUser : Error parsing query: 'Name -eq $arr[0].username' Error Message: 'Operator Not supported: ' at position: '1 4'. At line:1 char:19 + $user = get-aduser <<<< -filter {Name -eq $arr[0].username} + CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException + FullyQualifiedErrorId : Error parsing query: 'Name -eq $arr[0].username' Error Message: 'Operator Not supported: ' at position: '14'.,Microsoft.ActiveDirectory.Management.Commands.GetADUser
But, when I run:
$user = get-aduser -filter {Name -eq "user1"}
it works fine.
how can I find the users using $arr[0].username
?
what is the difference ? both of them strings:
"user1" and $arr[0].username
...
Thanks, for your help