I came across this in my powershell learning curve when using an object.
I read the user ID in the CSV file and needed to search / match / filter on them, and just like before double quotes, it didnβt work there.
My solution was to use the ToString () method for my object and set it to a scalar variable, and then use that variable in the filter. It works great.
$user_records=Import-CSV .\20140430.userids.csv
The table had three columns "Name, ID, Department." To get them in the search filter for my user ID, I used:
foreach ( $thisrow in $user_records ) { $thisuser=$thisrow.Username.ToString() Get-ADUser -Filter {SamAccountName -eq $thisuser} -SearchBase "OU=Domain Users,DC=topofthecharts,DC=com" -Properties Department
}
This completely prevented my extension and quotation marks.
Ernie
source share