Modify script to exclude OU from search

I have the following powershell script, i want to modify it so it exclude a certain OU when it runs

$Users = Get-QADUser -disabled
foreach ($User in $Users){
$User.description = (Get-Date).toshortdatestring()
move-QADObject $User -NewParentContainer 'MyDomain.company.com/NewYork/Users'
}

any help would be great

thanks
davidm27Asked:
Who is Participating?
 
IronboneCommented:
Hi

Try the following:

Get-Qaduser -disabled | where {$_.dn -notmatch 'CN=Users,DC=yourdomain,DC=com'}
0
 
davidm27Author Commented:
cheers, works perefectly. sorry for the delay in replying excellent solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.