Solved

Disable Inactive Active Directory Accounts POWERSHELL Script

Posted on 2011-03-21
5
1,358 Views
Last Modified: 2012-05-11
I'm sure this has been done plenty of times but I can't seem to find a script that will disable active directory accounts (OU = Users) after 90 days of inactivity and move them to another OU called 'Users - Disabled'.  Would anyone be able to provide me with a powershell script that would do this?

Server 2008 Standard SP2
0
Comment
Question by:cmb991
  • 4
5 Comments
 
LVL 6

Expert Comment

by:Draxonic
ID: 35185298
Does it have to be Powershell? I started writing a script of my own to do this, then found this one linked below, which did 90% of what I required and I just added a little customisation.

http://www.rlmueller.net/Programs/MoveOldComputers.txt
0
 
LVL 6

Expert Comment

by:Draxonic
ID: 35185328
Ah, my mistake... this is for computer accounts, sorry.

It shouldn't be too difficult to change to user accounts, though.

To disable a user's account, set the UserAccountControl attribute to 0x0202 (0x002 + 0x0200)

http://support.microsoft.com/kb/305144
0
 
LVL 6

Accepted Solution

by:
Draxonic earned 500 total points
ID: 35186710
0
 
LVL 1

Author Comment

by:cmb991
ID: 35220348
What would be the best way to do this, powershell or VB?  I'm starting to rethink of this issue and trying to figure out the best way.
0
 
LVL 6

Expert Comment

by:Draxonic
ID: 35224606
It doesn't really matter which way you do this.

In terms of programming, I understand that PS is more versatile for manipulation of Microsoft systems, but unless you're actually doing the programming, this is a moot point.

So, a choice of VB or PS is like a choice of bourbon or whiskey. Both will get you drunk, but it's simply a matter of which you prefer.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

863 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

22 Experts available now in Live!

Get 1:1 Help Now