#PSTip Enumerating available time zones

Note: This tip requires PowerShell 2.0 or above.

Some applications or scripts might require the presence of a specific time zone on the system to be able to execute the actions defined by the application. For example, your script might have to adjust to the date/time format used in the script or consider daylight savings to ensure the script or application task scheduling is accurate. This is just one example of a time zone-aware application.

For the time zone-awareness, we need to be able to identify what time zones are available. We can do this using the TimeZoneInfo .NET class.

PS> [TimeZoneInfo]::GetSystemTimeZones() | select Id, DisplayName

About the author: Ravikanth C

Ravikanth is the founder and editor of the PowerShell Magazine. He is also a PowerShell MVP who works at Dell Inc. He blogs at http://www.ravichaganti.com/blog and you can follow him on Twitter @ravikanth.

Related Posts

%d bloggers like this: