Powershell – Audit Active Directory Users Script

PowerShell can be used to quickly export a list of Active Directory users for auditing, documentation, or account reviews.

The following command retrieves all Active Directory user accounts and exports several commonly reviewed properties to a CSV file:

Get-ADUser -Filter * -Properties DisplayName,UserPrincipalName,Enabled,Department,Title |
Select-Object Name,DisplayName,UserPrincipalName,Enabled,Department,Title |
Export-Csv "C:\Temp\AD_Users.csv" -NoTypeInformation

Requirements

The Active Directory PowerShell module must be installed and available on the computer running the command. The account running the command must also have permission to read Active Directory user information.

Make sure the C:\Temp folder exists before running the command.

Information Included

The exported CSV contains:

  • Name
  • Display Name
  • User Principal Name
  • Account enabled or disabled status
  • Department
  • Job title

The resulting file is saved as:

C:\Temp\AD_Users.csv

How the Command Works

Get-ADUser -Filter * retrieves all Active Directory user accounts.

The -Properties parameter requests additional attributes that are not returned by Get-ADUser by default.

Select-Object determines which fields are included in the final report.

Export-Csv writes the results to a CSV file that can be opened in Excel or another spreadsheet application.

Leave a Reply