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.
[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.
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.
With more than fifteen years of IT experience, Don Jones is one of the world’s leading experts on the Microsoft business technology platform. He’s the author of more than 35 books, including Windows PowerShell: TFM, Windows Administrator’s Scripting Toolkit, VBScript WMI and ADSI Unleashed, PHP-Nuke Garage, Special Edition Using Commerce Server 2002, Definitive Guide to SQL Server Performance Optimization, and many more. Don is a top-rated and in-demand speaker and serves on the advisory board for TechMentor. He is an accomplished IT journalist with features and monthly columns in Microsoft TechNet Magazine, Redmond Magazine, and on Web sites such as TechTarget and MCPMag.com. Don is also a multiple-year recipient of Microsoft’s prestigious Most Valuable Professional (MVP) Award, and is the Editor-in-Chief for Realtime Publishers.