Menu & Search

Get-TimeZone in PowerShell

Get-TimeZone in PowerShell

The Get-TimeZone command in PowerShell returns the current Time Zone of a computer, or it can be used to list all available Time Zones which will be useful if you’re planning on making changes to timezones.

In this post I’m showing 2 examples of how to check Timezone with PowerShell:

# Get the Time Zone of a Local Computer in PowerShell
# Script to Output Available Time Zones to a Local CSV File

Get the Time Zone of a Local Computer in PowerShell

Running Get-TimeZone in PowerShell will return the currently set timezone of the local Windows Computer.

# get timezone powershell
Get-TimeZone
Get timezone PowerShell
The above shows we are on GMT Standard Time, UTC+00:00.

Script to Output Available Time Zones to a Local CSV File

The PowerShell script below will output all available timezones to a local directory.

# output available timezones to a local directory
$path = "c:\temp\"
$output_file_name = "timezones_available.csv"
$full_output_path = $path + $output_file_name

If(!(test-path $path))
{
    New-Item -ItemType Directory -Force -Path $path
}
Get-TimeZone -ListAvailable | Export-Csv -Path $full_output_path -NoTypeInformation -Force

I saved this script to my c:\temp and ran:

The CSV will contain all timezones available, which is useful if amending timezones. The Set-TimeZone Microsoft Documentation page will help with this task.

As ever, I hope this guide has been a useful one. Feel free to check out my PowerShell Tips page for more random PowerShell informational guides.

0 Comments