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

PowerShell: Expand Disk Volume to Maximum Size

# expandDisk.ps1 # version 0.02 $driveLetters=(Get-wmiobject win32_volume -filter 'DriveType=3 AND DriveLetter IS NOT NULL').DriveLetter function…

Windows 2012: How To Install DotNet Framework 2.0 & 3.0

If there're HTTPS/TLS issues, run this function: https://blog.kimconnect.com/powershell-enable-tls-1-2-on-legacy-servers/ Toggle WSUS registry key to off prior…

Linux: Using Bash to Search for Files Matching Certain Extensions

# using tree: list any files in a directory parentDirectory=/home tree --prune $parentDirectory # using…