• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 65
  • Last Modified:

Powershell script to disable inactivity after 15 days

Need to have a script to disable user accounts after 15 days of inactivity from a certain OU.
2 Solutions
Sekar ChinnakannuStaff EngineerCommented:
Hope this one you looking, Makw sure you customize based on your requirement like 15 days http://ad.kazakinfo.com/2013/10/powershell-auto-disabling-inactive-users/
Ajit SinghCommented:
Something like:

dsquery user "OU=Users,DC=Domain,DC=com" -inactive 4 | dsmod user -disabled yes

Open in new window

You can use MVP Joe Richards free solution oldcmp.exe & it works best.

OldCmp.exe -users -report -age 15
OldCmp.exe -users -age 15 -disable -format csv

Else, try this solution to identify and clean up inactive Active Directory user accounts:

Hope this helps!
Sam BloomCommented:
Here's a complete PowerShell solution that does AD cleanup for all sorts of inactive objects that should help: http://www.adaxes.com/blog/cleanup-active-directory-with-powershell.html
Shaun VermaakTechnical Specialist/DeveloperCommented:
CiscoAznAuthor Commented:
Thanks! This is really helpful.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

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