Powershell

How to Use the Get-TimeZone (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

While working in Powershell, developers often need to get the list of all available time zones or just want to know the current time zone, the “Get-TimeZone” cmdlet can be used. Moreover, this particular Powershell command is only available to Windows devices. The standard alias for the “Get-TimeZone” cmdlet is “gtz”.

This tutorial will provide the usage of PowerShell’s “Get-TimeZone” cmdlet.

How to Use the PowerShell Get-TimeZone Cmdlet?

In Powershell, the “Get-TimeZone” cmdlet is used for displaying the time zone. To get the current time zone, simply execute the “Get-TimeZone” cmdlet in PowerShell.

Syntax

The syntax of the “Get-TimeZone” cmdlet is:

Get-TimeZone [-ListAvailable] [<CommonParameters>]

Example 1: Use the Cmdlet “Get-TimeZone” to Retrieve the Current Time Zone

Run the below-stated command to get the system’s current time zone:

Get-TimeZone

Example 2: Use the Cmdlet “Get-TimeZone” to Retrieve the Time Zones Matching a Specified String

For getting the time zone that matches a particular string, first, use the “Get-TimeZone” cmdlet along with the “-Name” parameter and assign it the time zone enclosed within wild card characters:

Get-TimeZone -Name "*pac*"

Example 3: Use the “Get-TimeZone” Cmdlet to Retrieve the Available Time Zones

To retrieve all available time zones, first, use the “Get-TimeZone” cmdlet and then add the “-ListAvailable” parameter:

Get-TimeZone -ListAvailable

That’s it! You have learned the usage of the “Get-TimeZone” cmdlet in PowerShell.

Conclusion

The “Get-TimeZone” cmdlet is used to retrieve the current time zone in PowerShell. Moreover, it can also get the list of available and specified time zone. This article has elaborated on the use of PowerShell’s “Get-TimeZone” cmdlet.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.