Use PowerShell to ShortCut Getting Time Zone Information

August 27, 2009

in .Net,PowerShell,Time Zone,TimeZoneInfo

Colleague Dev Ashish posted about the challenges of Accessing ZoneInfo from Windows. He points out in .NET 3.5 the TimeZoneInfo class was added.

[System.TimeZoneInfo]::GetSystemTimeZones()

This command returns 89 entries and several properties.

image

More Examples

Get-TimeZones East

Find All TimeZones with ‘East’ in there ID.

Function Get-TimeZones ($id) {
    $where = {$_.Id -match "$id"}
    [System.TimeZoneInfo]::GetSystemTimeZones() |
        Where $where
}            

Get-TimeZones East            

 image

General Use

$TZI=[System.TimeZoneInfo]            

$TZI::Local
$TZI::Local.DaylightName
$TZI::Local.DisplayName
""
$TZI::FindSystemTimeZoneById("Tokyo Standard Time")

image

Other Resources

{ 1 trackback }

Time Zones in PowerShell | Adam Driscoll's Blog
02.13.12 at 9:28 pm

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Contrat Creative Commons

© 2007-2012, Doug Finke