get-aduser with filter involving two conditions

Hi guys, I’m trying to get the following line to work:

 foreach ($clientaccount in $(get-aduser -filter "givenname -eq '$usergivenname' -and surname -eq '$userSurname'" -searchbase ",OU=Client Accounts,OU=Example,OU=Groups,DC=corp,DC=example,DC=net")){ #do things in loop } 

I’ve verified that $usergivenname and $userSurname are defined and strings when that line runs.

I consistently get:

 get-aduser : The object name has bad syntax 

I think I need to implement something like this, but I can’t figure out how to use it with a compound condition

submitted by /u/whistlemix
[link] [comments]

Leave a Reply