Powershell script to disable inactivity after 15 days

CiscoAzn
CiscoAzn used Ask the Experts™
on
Need to have a script to disable user accounts after 15 days of inactivity from a certain OU.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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/
E ATech Lead

Commented:
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:
https://www.lepide.com/lepideauditor/active-directory-cleanup.html

Hope this helps!
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
Technical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:

Author

Commented:
Thanks! This is really helpful.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial