Skip to content

Instantly share code, notes, and snippets.

@DavoudTeimouri
Created March 23, 2023 15:44
Show Gist options
  • Select an option

  • Save DavoudTeimouri/6a69b70fea4722b4e218214b95589938 to your computer and use it in GitHub Desktop.

Select an option

Save DavoudTeimouri/6a69b70fea4722b4e218214b95589938 to your computer and use it in GitHub Desktop.
This script will decode TZI value from registry. Replace the bytes in the first line of the script with the TZI value in REG_BINARY format that you want to convert.
$tzi = [byte[]]@(0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
$bias = [System.BitConverter]::ToInt32($tzi, 0)
$standardBias = [System.BitConverter]::ToInt32($tzi, 4)
$daylightBias = [System.BitConverter]::ToInt32($tzi, 8)
$standardStart = [System.DateTime]::FromFileTime([System.BitConverter]::ToInt64($tzi, 12))
$daylightStart = [System.DateTime]::FromFileTime([System.BitConverter]::ToInt64($tzi, 20))
Write-Host "Standard bias from UTC: $bias minutes"
Write-Host "Standard offset from UTC: $standardBias minutes"
Write-Host "Daylight bias from UTC: $daylightBias minutes"
Write-Host "Standard start time: $standardStart"
Write-Host "Daylight start time: $daylightStart"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment