Powershell Script to disable inactive user accounts in AD

saravananvrblog

Developed a powershell script to report and disable inactive users in domain. This script will identify users inactive for last 60 days in domain. This script have two options; you can just pull out list of inactive users report and the second option is to disable the inactive users and while disabling it will add description to those accounts. Also it will generate an email alert to specified recepients with list of users as attachment.

Followings lines on the script to be changed according to your requirement

$searchRoot = “test.com/”   -> Change the domain name instead of test.com
$inactiveDays = 60   ->  If you want change number of days to identify inactive users

$toAddr = @(“user1@test.com”,”user2@test.com”) -> Change the email addresses to whom the alert to be sent.

$smtpsrv = “smtp.test.com” -> Update your SMTP server name or IP address

Steps to execute the script:

Install Quest Active directory powershell module on the system you are executing…

View original post 375 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s