Solved

Modify script to exclude OU from search

Posted on 2012-04-03
2
1,884 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
Comment Utility
Hi

Try the following:

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

Author Closing Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

10 Experts available now in Live!

Get 1:1 Help Now