GET-QADUSER ...Need to exclude OU

I

IT Staff

get-qaduser -searchroot 'dc=ABC,DC.COM' -includedproperties
usermustchangepassword,samaccountname | where {$_.usermustchangepassword -eq
'true'} | select name, samaccountname

==========================================
The above search from the root to end of every OU that i have. How can i
exclude specific OU in the cmd above ?

Eg

get-qaduser -searchroot 'dc=ABC,DC.COM' (exclude DN OU filter here) -
includedproperties, blah blah blah ...
 

My Computer

A

adrian

You can add another Where filter to exclude the OU. Use -notmatch so
you can key on the DN. It's slow, an ldap filter would be a lot faster
if you have a lot of users in your domain...

get-qaduser -searchroot 'dc=ABC,DC.COM' -includedproperties
usermustchangepassword,samaccountname |
where {$_.usermustchangepassword -eq 'true'} |
where {$_.dn -notmatch 'CN=Users,DC=yourdomain,DC=com'} |
select name, samaccountname



On Oct 14, 1:20 am, "IT Staff" <[email protected]> wrote:

> get-qaduser -searchroot 'dc=ABC,DC.COM'  -includedproperties
> usermustchangepassword,samaccountname | where {$_.usermustchangepassword -eq
> 'true'} | select name, samaccountname
>
> ==========================================
> The above search from the root to end of every OU that i have. How can i
> exclude specific OU in the cmd above ?
>
> Eg
>
> get-qaduser -searchroot 'dc=ABC,DC.COM' (exclude DN OU filter here) -
> includedproperties, blah blah blah ...
 

My Computer

Top