Get List of Users AD Password Expiration with Powershell

Just a couple good Powershell scripts for getting AD user password expirations.

List all users password expiration date (one-liner)

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "DisplayName", "mail", "msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "Displayname","mail",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | Out-GridView -Title "Users Password Expirations"

You can change the Out-GridView cmdlet at the end to export-csv or

How to Remove Home Folder Mapping for all AD Users

With so many businesses adopting Microsoft Office 365 or Google Apps for Work, users are now able to put more of their files in the cloud - thus replacing on-site server storage and user home directories. The below Powershell script will remove all user home folder mappings in Active Directory:

Get-AdUser -Filter * -Properties * | Foreach {
   Write-Host "- " $_.Name
   if ($_.HomeDrive -ne $null) {
    Write-Host -NoNewline "|-  Current home:" $_.HomeDrive "->"