Here is a useful little script to help you clean up your Active Directory. This PowerShell script outputs a .CSV file (so you can then edit and sort in Excel) which includes the User Name, Last Logon Date, Account Name, Distinguished Name, and Description.

Powershell Command to Produce a Table of All Disabled User Accounts in AD

Get-ADUser -Filter {Enabled -eq $false} -Properties Name, SamAccountName, DistinguishedName, Description, LastLogonDate | Select-Object Name, LastLogonDate, SamAccountName, DistinguishedName, Description | Export-Csv -NoTypeInformation -Path "C:\DisabledUsers.csv"


Leave a Reply

Avatar placeholder

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