$date = (get-date).AddDays(-90)
Get-ADUser -Filter {LastLogonDate -lt $date} -Property Enabled | Where-Object {$_.Enabled -like “true”} | Select Name, SamAccountName, DistinguishedName | Export-CSV “C:\Temp\Inactiveaccounts.csv” -NoTypeInformation
![](https://azuresmoke.com/wp-content/uploads/2021/12/Inactive-Users0-1024x175.png)
$date = (get-date).AddDays(-90)
Get-ADUser -Filter {LastLogonDate -lt $date} -Property Enabled | Where-Object {$_.Enabled -like “true”} | Select Name, SamAccountName, DistinguishedName | Export-CSV “C:\Temp\Inactiveaccounts.csv” -NoTypeInformation