We help IT Professionals succeed at work.

Powershell script to disable inactivity after 15 days

CiscoAzn
CiscoAzn asked
on
102 Views
1 Endorsement
Last Modified: 2017-11-08
Need to have a script to disable user accounts after 15 days of inactivity from a certain OU.
Comment
Watch Question

Sekar ChinnakannuStaff Engineer
CERTIFIED EXPERT

Commented:
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
CERTIFIED EXPERT

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!
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Senior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
Thanks! This is really helpful.