Reputation: 2838
I know how to get a list of computers in specific OU's using powershell, and I can use a like command to; however I am looking . How can I get a list of computers in two different OU's that start Like COMP using Powershell ?
Upvotes: 0
Views: 1113
Reputation: 174900
You could loop over the list of OUs and repeat the same query multiple times:
# fetch the target OUs
$OUs = Get-ADOrganizationalUnit -Filter "Name -like 'Comp*'"
# call Get-ADComputer once for each OU
$Computers = $OUs |ForEach-Object {
Get-ADComputer -Filter * -SearchBase $_.distinguishedName
}
Upvotes: 2