Solved

Modify script to exclude OU from search

Posted on 2012-04-03
2
1,960 Views
Last Modified: 2012-04-10
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
0
Comment
Question by:davidm27
2 Comments
 
LVL 3

Accepted Solution

by:
Ironbone earned 500 total points
ID: 37805633
Hi

Try the following:

Get-Qaduser -disabled | where {$_.dn -notmatch 'CN=Users,DC=yourdomain,DC=com'}
0
 

Author Closing Comment

by:davidm27
ID: 37827264
cheers, works perefectly. sorry for the delay in replying excellent solution
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This article will help you understand what HashTables are and how to use them in PowerShell.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question