Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Cleaner way to filter a Get-adcomputer query

$
0
0

I have a get-Adcomputer call that is working and I am wondering if there is a better/cleaner way to filter out multiple OU's than what I am currently doing..

Get-ADComputer -Filter * -SearchBase "OU=TC Workstations,DC=ad,DC=TC,DC=org" `
-Properties Description,Enabled,MemberOf,CanonicalName,OperatingSystem | `
Where {($_.CanonicalName -notlike "*/vdi*") -and ($_.CanonicalName -notlike "*/saf*") -and ($_.CanonicalName -notlike "*/atic*") `
-and ($_.CanonicalName -notlike "*/visix*") -and ($_.CanonicalName -notlike "*/DeletePending*")} | Sort-Object -Property Name

I have been searching but haven't found anything yet.

Thanks.


Viewing all articles
Browse latest Browse all 6937

Trending Articles