Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm am trying to get a list of the users in my AD Domain along with their password expiration. I have this so far in PowerShell:

get-aduser -filter * -properties "msDS-UserPasswordExpiryTimeComputed" | select name,samaccountname,@{Name="Expiry";Expression="msDS-UserPasswordExpiryTimeComputed"}

Which results in something like this:

name                       samaccountname                                Expiry
----                       --------------                                ------
longneck                   longneck                          129802700808178073

How can I convert that Expiry column to a datetime? I've tried this:

get-aduser -filter * -properties "msDS-UserPasswordExpiryTimeComputed" | select name,samaccountname,@{Name="Expiry";Expression={[datetime]::FromFileTime("msDS-UserPasswordExpiryTimeComputed")}}

But that just results in a blank Expiry column.

name                       samaccountname                                Expiry
----                       --------------                                ------
longneck                   longneck                          

What am I doing wrong?

share|improve this question
up vote 1 down vote accepted

You're missing the $_ to indicate which object's msDS-UserPasswordExpiryTimeComputed attribute to use in your expression. The $_ variable is the default current object in the pipeline. You would find the value in $_."msDS-UserPasswordExpiryTimeComputed".

Get-ADUser -Filter * -Properties "msDS-UserPasswordExpiryTimeComputed" | 
  Select-Object name,samaccountname,@{Name="Expry";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.