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

Daily database backup.bat

@echo offif %USERNAME%==Administrator echo you are administratorset RAREXEC="C:\Program Files\WinRAR\WinRar.exe"set RAREXEC="C:\Program Files\WinRAR\Rar.exe"set LOGFILE="c:\sys\backup.log"SET ARG1=%1IF EXIST D:\…

Recommended Skill Set of a Programmer

It's a given that a coder needs to learn how to code... like really well.…

PowerShell: Use WinSCP to Test a SFTP Connection

# testSftpConnect.ps1 # Quick script to test SFTP connectivity $username='FTPUSER' $password='PASSWORD' $sftpServer='x.x.x.x' $sftpPort=22 function testSftpConnect($sftpServer,$username,$password,$sftpPort){…