Showing posts with label active directory users not logged last 30 days. Show all posts
Showing posts with label active directory users not logged last 30 days. Show all posts

Tuesday 6 June 2017

Exporting inactive AD users to CSV file using PowerShell command

Or, PowerShell command to export inactive AD uses in to a CSV file
Or, Get inactive AD users report with the help of PowerShell

Descriptions:  If you are looking for exporting inactive AD users in to a CSV file/report, this article is for you my friend. In my case, I am going to export users whoever are inactive since 30 days.

Steps:
Run Windows PowerShell as Administrator > run the commands mentioned below to get the CSV output/report

Inactive AD users since 30 days

Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 30 | ?{$_.enabled -eq $True} | Get-ADUser -Properties Name, EmailAddress, Department, Description, lastLogonTimestamp | Select Name, EmailAddress, Department, Description,@{n='lastLogonTimestamp';e={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} | Export-Csv D:\temp\funytest.csv


Cheers, Please write me back if you have any query or feedback on this.