Powershell convert Int64 TimeStamp to DateTime

Last updated:

POWERSHELL

we can use the .Net function FromFileTime and convert the output to DateTime format.

$timestamp = "131099683087123361"
[DateTime]::FromFileTimeutc($timestamp)

Example with aduser report

Get-ADUser -Server $Domain -Properties * | Select DisplayName,DistinguishedName,Description,PasswordNeverExpires,@{n="PwdLastSet";e={[datetime]::FromFileTime($_."PwdLastSet")}}

references: