Disable Inactive Users in Active Directory

Overview

Disable all Active Directory users in a domain or a specified OU that have not logged on and were not created within X days and save the list to a csv file.

Download Disable Inactive Users Power-Shell Script

Disable-Inactive-AD-Users @ GitHub

Settings

Edit the script file and replace the following values:

  • Log folder:
    $LogFolder = “C:\Disable-Inactive-AD-Users\”
  • Search base – Domain or Organizational Unit to search – use Distinguished Name (DN)
    $OU = “OU=MyUsers,DC=domain,DC=com”
  • Period of time (in days) a user has been inactive
    $UnusedDays = 365

Disable Inactive Users in Active Directory

Enjoy

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.