Skip to content

Instantly share code, notes, and snippets.

@elreydetoda
Last active September 25, 2025 13:54
Show Gist options
  • Select an option

  • Save elreydetoda/d53e11fc0dfc8a017fca549a2347560c to your computer and use it in GitHub Desktop.

Select an option

Save elreydetoda/d53e11fc0dfc8a017fca549a2347560c to your computer and use it in GitHub Desktop.
used to make windows recognize the bios clock as UTC, which is used by a lot of *nix distros, and will screw up your time if you dual boot.

Set your time to UTC in windows

(this post short url: https://git.io/JfvEl)

launch a run prompt

WindowsKey + R

start a powershell process as admin

type in the run prompt: powershell start-process powershell -verb runAs

Accept UAC prompt

Hit the keys Alt + y

don't download the script and execute in mem (i.e. curl | bash)

execute downloaded object (i.e. the raw form of the Set-WindowsUTCTime.ps1

iex (new-object system.net.webclient).DownloadString("https://git.io/JfvET")

or the longer url

iex (new-object system.net.webclient).DownloadString("https://gist.githubusercontent.com/elreydetoda/d53e11fc0dfc8a017fca549a2347560c/Set-WindowsUTCTime.ps1")

download script and ./ to execute

Download script

Invoke-WebRequest -OutFile Set-WindowsUTCTime.ps1 "https://gist.githubusercontent.com/elreydetoda/d53e11fc0dfc8a017fca549a2347560c/raw/d98d424f60479f69ad891ebe1a666fd0102e48d9/Set-WindowsUTCTime.ps1"

Bypass script policy for this powershell instance

thank you @jaredhaight

Set-ExecutionPolicy Bypass -Scope Process

Execute

./Set-WindowsUTCTime.ps1

after initial execution

just run the following after you have run the script once. That will resync the time service to the proply configured time. NOTE: you will need to execute the command as Admin. So look here for that.

w32tm /resync

Searching through windows history

simple

once you have executed the command, you should be able to go back by just hitting the up arrow in your powershell terminal

efficient

  • You can hit Ctrl + r to start searching through your history.
  • start typing w32 and it should show up
  • Then hit Enter to execute again.
# script came from: https://devblogs.microsoft.com/scripting/update-or-add-registry-key-value-with-powershell/
# values for script came from: https://weblogs.asp.net/dfindley/Set-hardware-clock-to-UTC-on-Windows-_2800_or-how-to-make-the-clock-work-on-a-Mac-Book-Pro_2900_
# Registry path for where the key should go
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
# name of registry key you are adding
$Name = "RealTimeIsUniversal"
# value of key
$value = "1"
# make sure path exists
IF(!(Test-Path $registryPath))
{
# create path if it doesn't
New-Item -Path $registryPath -Force
}
# add registry key and value
Write-Output "Adding utc registry key"
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force
# make sure windows time service is runnning
Write-Output "Starting windows time service"
net start "Windows Time"
Write-Output "Sleeping for 5 seconds"
Start-Sleep 5
# syncing windows time so it uses new utc time setting read more here: https://weblogs.asp.net/dfindley/Set-hardware-clock-to-UTC-on-Windows-_2800_or-how-to-make-
Write-Output "Syncing time service with new key added"
w32tm /resync
Write-Output "Congrats, you will need to give it a few second, but you should now have the time service running that will adjust your time to the necssary UTC conversion"
Write-Output "So from now on you will only need to do the following to synchronize the service"
Write-Output "w32tm /resync"
Write-Output "execute the command above (i.e. copy and paste it) now, so you can simple search through your windows history to find it later."
@real-kami-kun
Copy link

So do I have to run the /resync command every time I switch OSes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment