Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Hey PowerShell Guy!, How Can I Retrieve Time Zone Information for a Computer?

As you can see in former posts also I picked up my Hey PowerShell guy series again, I did stop when the ScriptCenter started to provide PowerShell examples also see : Hey, PowerShell Guy ! How Can I .. Sorry forget about it I allready Know .

But this stopped after a short time, I talked about this with the Scripting Guys at the IT Forum, June Blender from the PowerShell team did do the translations  , but she is very busy doing great work on the PowerShell documentation  and she did this all on personal account.

Hence I picked up again and while the Scripting Guy's are on holiday , and I have also some free time to spare again I will work a bit trough the archives : Hey, Scripting Guy! Archive by Date

In this post I will provide a translation for :

How Can I Retrieve Time Zone Information for a Computer? 

I prototyped this as a oneLiner :

if ((gwmi -q 'Select * From Win32_ComputerSystem').DaylightInEffect){gwmi -q 'Select * From Win32_TimeZone' | fl DaylightName}else{gwmi -q 'Select * From Win32_TimeZone' | fl StandardName}

A bit more "ScriptLike" :

if ((get-WmiObject -Query 'Select * From Win32_ComputerSystem').DaylightInEffect){

    get-WmiObject -Query 'Select * From Win32_TimeZone' | Format-List DaylightName

}else{

    get-WmiObject -Query 'Select * From Win32_TimeZone' | Format-List StandardName
}

As this does not very much differ from the Vbscript version, looking at both versions side by side gives a good impression of the syntax differences 

Enjoy, 

Greetings /\/\o\/\/

 PS Sorry  June, you working hard for my CTP Doc's and I stealing the making fun of VbScript here in the meanwhile, .. but thanks !

Published Friday, December 14, 2007 4:29 PM by MoW
Filed under: ,

Comments

# Interesting Finds: December 15, 2007

Saturday, December 15, 2007 10:39 AM by Jason Haley

# PowerShell get-Worldtime function

As we are running for a new year again,Some more timeZone fun, I did a WMI example here : Hey PowerShell

Wednesday, December 19, 2007 3:02 PM by The PowerShell Guy

# Hey Scripting guy !

After a silent changing of guards : About The Scripting Guys The new Scripting guy's  Ed Wilson

Sunday, October 05, 2008 5:35 AM by The PowerShell Guy

# Use PowerShell to ShortCut Getting Time Zone Information

Thursday, August 27, 2009 11:31 AM by Use PowerShell to ShortCut Getting Time Zone Information
Anonymous comments are disabled