Posted On June 29, 2022

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

kimconnect 0 comments
blog.KimConnect.com >> Codes >> 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 *

Related Post

Renew or Replace a SSL Certificate in Dynamics CRM

Error Message: "Exchange Online Security Certificate Expiration Please update your certificate or Exchange Online integration…

PowerShell: Quickly Start Services that were Set to Auto

Quick Liners: # Command to checkGet-WmiObject -ClassName Win32_Service -Filter "StartMode='Auto' AND State<>'Running'" | Format-Table -Auto…

PowerShell: Reset Failover Clustering Quorum

# Adding Prerequisite Microsoft ClusterFunction installFailoverClustersModule{if (!(get-module -Name "FailoverClusters") ){#Install-WindowsFeature Failover-Clustering | out-null;Install-WindowsFeature RSAT-Clustering-MGMT |…