Published at

Export AD Audit details to a CSV File

Export AD Audit details to a CSV File

Learn how to export AD Audit details to CSV.

Table of Contents

Active Directory Audit

This is a very useful script I wrote to generate a .csv that shows valuable information from Active Directory.

$OutputPath = "c:\\support\\users.csv"  
  
$Year = "2019"  
  
$filename = "$($Year)\_users.csv"  
  
$YearUsers = Get-ADUser -Filter  {(Enabled -eq "True")} -Properties created, lastlogondate,passwordlastset,passwordneverexpires  
  
$YearUsers | select name, samaccountname, created,lastlogondate,passwordlastset,passwordneverexpires |  

Export-Csv -Path $OutputPath$filename -NoTypeInformation -Force