PowerShell: Converting Time Stamp from Int64 to DateTime and Vice Versa

Here are some quick conversion methods between time values represented by Integer and DateTime data types:

# Convert from LastlogonTimeStamp to Date Time
[DateTime]::FromFileTime($_.LastLogon)
# Convert from DateTime to Lastlogon TimeStamp
$daysLimit=30
$limitTimestamp=(get-date).AddDays(-$daysLimit).ToFileTime()
$limitTimestamp.ToFileTime()

Leave a Reply

Your email address will not be published. Required fields are marked *