Mr. Roboto

Does Anybody Really Know What Time It Is?

Use this script to find out which time zones your computers are in.

I admit, it seemed kind of silly when someone told me, "we have no idea what time zone our computers are set for, and it’s causing problems." What, were the computers showing up late for dinner or something?

It turns out that the time zone setting in Windows is very important in Active Directory domains. Time synchronization is essential to authentication, not to mention the time displayed in the system clock in the Task Bar. For this particular person, the time zone offset was also affecting a corporate application, causing incorrect timestamps to be logged to a database application. In short, the wrong time zone setting was messing up a lot more than just dinner plans.

And, strangely, I couldn’t find any tools that could readily inventory a batch of computers to tell me exactly which time zone they were on. It seemed like it should be a pretty straightforward task, so I built a tool to do it. Like many of the tools I make, this one’s in VBScript.

If you’re not a scripter, don’t worry, because you can use it just like any other command-line tool. Run it with /? to see available options. Or, to check a list of computers, just run listtimezone /list:computers.txt /ping. The /ping argument forces the tool to ping computers before trying to query them; note that you’ll need to be able to connect to each targeted computer via RPC, and you’ll need to be a local Administrator on each computer in order for the tool to query the information. Figure 1 shows two runs of the tool: Once with the optional /verbose switch that provides more detailed output, and once without, just showing the time zone offset (-480) for each targeted computer.

What does a time zone offset of -480 mean? It’s the amount of time, in minutes, that the time zone setting in the queried system is behind Greenwich Mean Time (GMT) -- also known as Universal Time Constant (UTC). So a value of -480 indicates a PC that is eight hours behind GMT, which corresponds to Pacific Standard Time (PST). Each computer in a given location should ideally have the same time zone offset; any that doesn’t deserves your immediate attention.

Where am I?
[Click on image for larger view.]
Figure 1. The results of the script to find a
computer’s time zone.

While remotely setting time or time sync is easy with the built-in Net Time command, remotely setting the time zone can be trickier. Without the correct time zone setting, time sync won’t work properly. Time sync always works on GMT/UTC; the computer’s local time is calculated using the configured time zone setting, so if the time zone’s wrong, local time will be off.

DownLoad

Download this month's tool from www.ScriptingAnswers.com/roboto/col4.zip

Obviously, a Remote Desktop connection makes it easy to change the time zone, as does just walking over (if that’s possible) and doing it manually. Weirdly, I still can’t find any good tools to remotely change the time zone; I can’t even find it in a Group Policy setting, which would be the perfect place (just link the GPO to a site, right?) for it. You can write a script to modify HKEY_LOCAL_MACHINESYSTEM\CurrentControlSetControl\TimeZoneInformation in the registry, but I’ve had some inconsistent results with that -- an OS restart seems to be required in order for Windows to re-read that key.

I’ll keep plugging away on this, but in the meantime you’ve got a tool that can at least identify rogue time zone miscreants in your environment. And knowing, as they say, is half the battle.

About the Author

Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is an Author/Evangelist for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.

comments powered by Disqus

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.