question

PaulSquittieri-3337 avatar image
0 Votes"
PaulSquittieri-3337 asked PaulSquittieri-3337 commented

Filter in Powershell


with the command below I'm trying to filter multiple OU Name. I've tried many different things on the filter and every time it breaks the filter. basically I'm trying to filter everything i dont want to see in the list

Name -notlike "groups"
Name -notlike "AccountsDisabled"
Name -notlike "Accounts Disabled"

$OUs = Get-ADOrganizationalUnit -filter 'Name -notlike "Groups"' -SearchBase 'OU=Accounts,DC=domain,DC=com' -SearchScope subtree -Properties Name, DistinguishedName | Sort-Object Name

windows-server-powershellwindows-active-directory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered PaulSquittieri-3337 commented

Have you tried it like this?

 "Name -notlike '*groups*' -AND Name -notlike '*AccountsDisabled*' -AND Name -notlike '*Accounts Disabled*'"
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

that worked, thank you

0 Votes 0 ·