How can I use Powershell/CMD on Windows to get the current time in the Windows FILETIME format? Something like this answer about Linux except for Windows, using the Windows FILETIME format (time since 1600 in 100-nanosecond intervals), and preferably something simple like the aforementioned answer.
>Solution :
# Returns a FILETIME timestamp representing the current UTC timestamp,
# i.e. a [long] value that is the number of 100-nanosecond intervals
# since midnight 1 Jan 1600, UTC.
[datetime]::UtcNow.ToFileTime()
Alternatives: [dateime]::Now.ToFileTimeUtc() or [datetimeoffset]::Now.ToFileTime()
To convert such a FILETIME value back to a [datetime] instance:
[datetime]::FromFileTime(
[datetime]::UtcNow.ToFileTime()
)
Note: The above yields a local [datetime] instance (its .Kind property is Local); alternatively, use [datetimeoffset]::FromFileTime(), which allows you to obtain a local (.LocalDateTime) or a UTC (.UtcDateTime]) [datetime] instance, as needed.