Avatar of CiscoAzn
CiscoAzn
Flag for United States of America asked on

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.
PowershellActive Directory

Avatar of undefined
Last Comment
CiscoAzn

8/22/2022 - Mon
Sekar Chinnakannu

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 A

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!
SOLUTION
Sam Bloom

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
CiscoAzn

ASKER
Thanks! This is really helpful.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes