August 27th, 2014

PowerTip: Use PowerShell to Change System Time

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to change the system time.

Hey, Scripting Guy! Question The clock on my computer (running Windows 8.1) is 30 minutes slow. How can I use Windows PowerShell 
            to move the system time up 30 minutes?

Hey, Scripting Guy! Answer Use the Set-Date cmdlet, create a TimeSpan object equal to 30 minutes, and supply it to
            the –adjust parameter:

Set-Date -Adjust (New-TimeSpan -Minutes 30)

To alter the clock back 30 minutes, create a negative TimeSpan, for example:

Set-Date -Adjust (New-TimeSpan -Minutes -30)

Note  This cmdlet requires credentials to set the time. One way to get this privilege is to open
Windows PowerShell as an administrator.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.