Skip to content

Export AD Audit details to CSV

Published: at 02:20 PM

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