[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

I need a GP for moving diabled users to a predefined "Disable User" OU

Windows 2003 AD
We are a service provider - 80% of our user community is in the field
our attrition rate is high -
I need a group policy to migrate disabled users from one OU to a disabled user OU when the user is terminated.
0
acreeit
Asked:
acreeit
1 Solution
 
Chris DentPowerShell DeveloperCommented:

It would have to be a script rather than policy, but that's not a big problem.

How do you define / locate terminated users within AD?

Chris
0
 
Henrik JohanssonSystems engineerCommented:
As Chris said, you nead to script it.
One way is to use dsquery and dsmove from adminpak.msi
for /F %a in ('dsquery user OU=old-ou,DC=domain,DC=com -disabled') do @dsmove %a -newparent OU=disabled-users,DC=domain,DC=com
0
 
PakaCommented:
How about piping the result:
dsquery user -disabled -limit 0 | dsmove user -newparent "ou=disabled, dc=mydomain, dc=com"
(where | is shift-\)  This will move all disabled users in all OUs in your domain to an the disabled OU.  

If you want to preview the accounts that would move:
dsquery user -disabled -limit 0 > disabledusers.txt

If you want to move just 10 accounts (as a test):
dsquery user -disabled -limit 10 | dsmove user -newparent "ou=disabled, dc=mydomain, dc=com"
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
acreeitAuthor Commented:
Can this be automated so that once the Helpdesk disabled the account it is automatically moved to diabled OU?
HOW do I do this?
0
 
Henrik JohanssonSystems engineerCommented:
Place the command line in a script.cmd file and create a schedule task to run the script at a recurring times on the DC.
Keep in mind that %a in for-loop nead to be replaced with %%a when using script files. The single %a is used when executing command directly in command prompt.
0
 
acreeitAuthor Commented:
Thank you willl test
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now