Solved

Modify script to exclude OU from search

Posted on 2012-04-03
2
1,932 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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now