Hi everyone,
I'm wanting to generate a report of inactive users for the past 90 days using PowerShell, and being a PowerShell newbie need a bit of help getting it over the line. In addition to 90 day inactive condition, no disabled user accounts should be included in the report. This is the command I'm using, however the select on the givenname and surname fields is not returning any data.
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 | ?{$_.enabled -eq $true} | select name, givenname, surname | export-csv c:\report\unusedaccounts.csv -NoTypeInformation
This report is for management so I need to have the users actual name to accompany their username. Any suggestions for where I am going wrong here?