OS: |
Windows |
Type: |
A Windows PowerShell script |
Language: |
Windows PowerShell |
Description: |
Get-TimeZoneTable queries the general Time Zone information list from the Windows registry under the "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\ " key and stores the found properties (subkeys, of which, in essence, each subkey contains the data of an individual time zone) as an collection of objects. In addition to the Windows registry query Get-TimeZoneTable uses Windows Management Instrumentation (WMI) to retrieve the current Time Zone and other basic computer information. The results are displayed in a pop-up window (Out-GridView), written to a HTML Time Zone Table -file and to a CSV-file. The files are saved to the path defined by a parameter called -Path and -Sort and -Descending parameters toggle, how the results are written to those files. |
Homepage: |
https://github.com/auberginehill/get-time-zone-table
Short URL: http://tinyurl.com/h5z2de6 |
Version: |
1.0 |
Sources: |
|
Downloads: |
For instance Get-TimeZoneTable.ps1. Or everything as a .zip-file. |
📐 |
-
which has an alias called -ReportPath (so they both act exactly the same way). The -Path parameter specifies where the HTML Time Zone Table and the adjacent CSV-file is to be saved. The default save location is $env:temp , which points to the current temporary file location, which is set in the system. The default -Path save location is defined at line 12 with the $Path variable. If no save location is defined in the command, the files are saved to $env:temp .
It's not always mandatory to write -Path in the command to invoke the -Path parameter, as is shown in the Examples below, since Get-TimeZoneTable is trying to decipher the inputted commands as good as it is machinely possible within a 50 KB size limit.
The save location path should be a valid file system path to a directory (a full path name of a directory (i.e. folder path such as C:\Windows )). In case the path name includes space characters, please add quotation marks around the path name. For usage, please see the Examples below and for more information about $env:temp , please see the Notes section below.
|
|
-
Specifies which column is the primary sort column in the HTML Time Zone Table and other outputs. Only one column may be selected in one command as the primary column. If -Sort parameter is not defined, Get-TimeZoneTable will try to sort by Date (Current), Time (Current) and Time Zone Id in an ascending order.
In the HTML Time Zone Table and other outputs all the headers are sortable (with the commands) and some headers have aliases, too. Valid -Sort values are listed below. Please also see the Examples section for further usage examples.
Value |
Sort Behavior |
"Time Zone Id" |
Sort by Time Zone Id |
Name |
Sort by Time Zone Id |
Id |
Sort by Time Zone Id |
English |
Sort by Time Zone Id |
"Date (Current)" |
Sort by Date (Current) |
Date |
Sort by Date (Current) |
"Time (Current)" |
Sort by Time (Current) |
Time |
Sort by Time (Current) |
Offset |
Sort by Offset |
Display |
Sort by Offset |
Value |
Sort by Offset |
UTC |
Sort by UTC |
Area |
Sort by Area |
"Standard Time (in system language)" |
Sort by Standard Time (in system language) |
"Standard Time" |
Sort by Standard Time (in system language) |
Standard |
Sort by Standard Time (in system language) |
Winter |
Sort by Standard Time (in system language) |
"Daylight Saving Time (in system language)" |
Sort by Daylight Saving Time (in system language) |
"Daylight Saving Time" |
Sort by Daylight Saving Time (in system language) |
Daylight |
Sort by Daylight Saving Time (in system language) |
Summer |
Sort by Daylight Saving Time (in system language) |
PSDrive |
Sort by PSDrive |
PSPath |
Sort by PSPath |
-
A switch to control how directories get sorted in the HTML Time Zone Table and other outputs, when also the -Sort parameter is used. By default Get-TimeZoneTable tries to sort everything in an ascending order. After defining the primary sort column with the -Sort parameter the prevalent ascending sort order may be reversed by adding the -Descending parameter to the command.
|
➡️ |
- Generates an HTML Time Zone Table and an adjacent CSV-file in a specified Path (
$Path = "$env:temp" at line 12), which is user-settable with the -Path parameter. Displays the prevalent time zone in console. In addition to that...
|
|
- One pop-up window "
$results_selection " (Out-GridView) with sortable headers (with a click):
Name |
Description |
$results_selection |
Displays the Time Zone Table |
- And also the aforementioned HTML-file "Time Zone Table" and CSV-file at
$Path . The HTML-file "Time Zone Table" is opened automatically in the default browser after the query is finished.
Path |
Type |
Name |
$env:temp\time_zones.html |
HTML-file |
time_zones.html |
$env:temp\time_zones.csv |
CSV-file |
time_zones.csv |
|
⚠️ |
- Please note that all the parameters can be used in one query command and that each of the parameters can be "tab completed" before typing them fully (by pressing the
[tab] key).
|
|
- Please also note that the two files are created in a directory, which is end-user settable in each query command with the
-Path parameter. The default save location is defined with the $Path variable (at line 12) and the -Path parameter also has an alias called -ReportPath . The default save location $env:temp variable points to the current temp folder. The default value of the $env:temp variable is C:\Users\<username>\AppData\Local\Temp (i.e. each user account has their own separate temp folder at path %USERPROFILE%\AppData\Local\Temp ). To see the current temp path, for instance a command
[System.IO.Path]::GetTempPath()
may be used at the PowerShell prompt window [PS>] . To change the temp folder for instance to C:\Temp , please, for example, follow the instructions at Temporary Files Folder - Change Location in Windows, which in essence are something along the lines:
- Right click on Computer and click on Properties (or select Start → Control Panel → System). In the resulting window with the basic information about the computer...
- Click on Advanced system settings on the left panel and select Advanced tab on the resulting pop-up window.
- Click on the button near the bottom labeled Environment Variables.
- In the topmost section labeled User variables both TMP and TEMP may be seen. Each different login account is assigned its own temporary locations. These values can be changed by double clicking a value or by highlighting a value and selecting Edit. The specified path will be used by Windows and many other programs for temporary files. It's advisable to set the same value (a directory path) for both TMP and TEMP.
- Any running programs need to be restarted for the new values to take effect. In fact, probably also Windows itself needs to be restarted for it to begin using the new values for its own temporary files.
|
📖 |
To open this code in Windows PowerShell, for instance: |
|
./Get-TimeZoneTable
Run the script. Please notice to insert ./ or .\ before the script name. Uses the default location ($env:temp ) for storing the generated HTML Time Zone Table and the adjacent CSV-file to. Outputs the Time Zone Table also in in a pop-up window (Out-GridView). The data is sorted by Date (Current), Time (Current) and Time Zone Id in an ascending order.
help ./Get-TimeZoneTable -Full
Display the help file.
./Get-TimeZoneTable -Path "C:\Scripts"
Run the script and store the two Time Zone Table files to C:\Scripts. The output is sorted, as per default, on the properties Date (Current), Time (Current) and Time Zone Id in an ascending order. Since the -Path variable has an alias of -ReportPath, a command
./Get-TimeZoneTable -ReportPath "C:\Scripts"
will do the exactly same thing. Please note that the -Path is not mandatory in this example and that the quotation marks can be left out, since the path name doesn't contain any space characters (./Get-TimeZoneTable C:\Scripts ).
./Get-TimeZoneTable -Path E:\chiore -Sort psdrive -Descending
Run the script and save the files to E:\chiore . Sort the data based on the "PSDRIVE" column and arrange the rows as descending so that the last alphabets come to the top and first alphabets will be at the bottom. To sort the same query in an ascending order the -Descending parameter may be left out from the query command (./Get-TimeZoneTable -Path E:\chiore -Sort psdrive ).
./Get-TimeZoneTable -Path C:\Scripts -Sort daylight -Descending
Run the script and save the HTML Time Zone Table and the adjacent CSV-file to C:\Scripts . Sort the data by the column name "Daylight Saving Time (in system language)" in a descending order. This command will work, because daylight is defined as an alias to the "Daylight Saving Time (in system language)" in the script. Please also note, that -Path can be omitted in this example, because a command
./Get-TimeZoneTable C:\Scripts -Sort daylight -Descending
in essence, has an exact same outcome.
Set-ExecutionPolicy remotesigned
This command is altering the Windows PowerShell rights to enable script execution. Windows PowerShell has to be run with elevated rights (run as an administrator) to actually be able to change the script execution properties. The default value is "Set-ExecutionPolicy restricted ".
Parameters:
Restricted |
Does not load configuration files or run scripts. Restricted is the default execution policy. |
AllSigned |
Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer. |
RemoteSigned |
Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher. |
Unrestricted |
Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs. |
Bypass |
Nothing is blocked and there are no warnings or prompts. |
Undefined |
Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope. |
For more information, please type "help Set-ExecutionPolicy -Full " or visit Set-ExecutionPolicy.
New-Item -ItemType File -Path C:\Temp\Get-TimeZoneTable.ps1
Creates an empty ps1-file to the C:\Temp directory. The New-Item cmdlet has an inherent -NoClobber mode built into it, so that the procedure will halt, if overwriting (replacing the contents) of an existing file is about to happen. Overwriting a file with the New-Item cmdlet requires using the Force .
For more information, please type "help New-Item -Full ".
|
Find a bug? Have a feature request? Here is how you can contribute to this project: