The Get-TimeZone
cmdlet in PowerShell retrieves the current time zone of a computer. It can also list all available time zones, which is helpful if you’re planning to make changes to the system’s time zone settings.
In this post I’m sharing two examples of how to check the local time zone with PowerShell:
> Get Time Zone using PowerShell
> Script to Output Available Time Zones to a CSV File
Get the Time Zone using PowerShell
Running Get-TimeZone
in PowerShell will return the currently set timezone of the local Windows Computer.
# get timezone powershell Get-TimeZone
Script to Output Available Time Zones to a CSV File
The following PowerShell script outputs all available time zones to a CSV file in a specified 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 folder and ran it:
The CSV will contain all time zones available:
This isn’t really a regular or task that you’d be doing often. I’m more just noting a different way of saving this info.
Leave a Reply