Active Directory

Export AD Users Password Expiration Report to CSV with Powershell 

We can export powershell output into CSV file using Export-CSV cmdlet. The following powershell command export selected properties and password expiry date of all the enabled Active Directory users to csv file.

Import-Module ActiveDirectory

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} ` –Properties "SamAccountName","mail","pwdLastSet","msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "SamAccountName","mail",@{Name="Password Last Set";` Expression={[datetime]::FromFileTime($_."pwdLastSet")}}, @{Name="Password Expiry Date";` Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | Export-CSV "C:\YourPasswordExpirationReport.csv" -NoTypeInformation -Encoding UTF8

No comments:

Post a Comment