title: Will Office 365 (Admin center or Powershell) tell me if a user's password is expired?
body: <p>I feel like this question has to have been asked before, but I've spent way too much time searching for it here and elsewhere.</p>
  
  <p>I'm looking for something to tell me that a user's password has expired. When I search for this, I get a ton of sites telling me how to set a user's password to never expire or how to set the password policy. I just want to be able to look up a user in the Admin Center or using PowerShell to see if the password is expired.</p>
  
  <p>I user this cmdlet as a workaround for the moment, but it would be so much easier if I could have it tell me "Password Expired: Yes" or something like that.</p>
  
  <pre><code>Get-MsolUser -SearchString (Read-Host `n Whose info?) | select DisplayName, LastPasswordChangeTimeStamp, @{Name=”PasswordAge (in days.time)”;Expression={(Get-Date)-$_.LastPasswordChangeTimeStamp}}, PasswordNeverExpires | fl
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>04-Aug-16 Edit based on Junaid's suggested answer below:</strong></p>
  
  <p>I've changed the script to allow for searching, for vertical spacing, and for the accounts where PasswordNeverExpires = TRUE. I hope it's helpful.</p>
  
  <pre><code>$valid = Get-MsolPasswordPolicy -DomainName domain.com | select ValidityPeriod -ExpandProperty ValidityPeriod
  
  Get-MsolUser -SearchString (Read-Host `n Whose info?) | Select DisplayName, LastPasswordChangeTimeStamp, PasswordNeverExpires | foreach{ 
   $user = $_.DisplayName
   $exp = $_.LastPasswordChangeTimeStamp.addDays($valid)
   If ($_.PasswordNeverExpires -eq $TRUE){
   $exp = "Never"
   }
   Write-Output "$user's Password Expiration: $exp"
  }
  Write-Output `n
  </code></pre>