Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Get-ADUser -Filter string array

$
0
0

The -Filter param on each cmdlet uses that cmdlet's provider to filter results vs. using something like -Include or Where-Object. You could get this done via Where-Object but I don't recommend it since it'd be a lot slower.

You could do something like this:

$userarray = 'user1','user2',user3'
$filterstring = "samaccountname -eq '$($userarray -join "' -or samaccountname -eq '")'"
Get-AdUser -Filter $filterstring

That just creates a string from the contents of your user array.


Viewing all articles
Browse latest Browse all 13067

Trending Articles