A Quick Lesson in Boolean

I often see scripts that are checking for True/False values using an If/Else statement like the one below.

if($value){
    'True'
} else { 
    'False'
}

While this technically will work for Boolean values, there are situations where this will not work. For example, if you pass the string value of “False” to the statement above it will evaluate as True. This is because the if condition in that code is not checking for True, it is checking for if exists. In that statement anything that is not Boolean False, Null, an empty string, or 0 will return True. However, if you specify a value must be true or false, PowerShell will auto-convert things like the string equal to ‘False’ as actually being false.

This is why I always recommend using the full condition of if($value -eq $true). Not only will this give you the ability to account for variables you may not be able to control, it also gives you a way to handle non-Boolean values. You can test it out for yourself using the snippet below, and see how the different ways of writing this If/Else statement work out.

Function Test-Boolean($value, $test){
    if($value -eq $true){
        $Result='True'
    } elseif ($value -eq $false) { 
        $Result='False'
    } else {
         $Result='Else'
    }

    if($value){
        $IfElse = 'True'
    } else { 
        $IfElse = 'False'
    }

    [pscustomobject]@{TrueFalse=$Result;IfElse=$IfElse;Value=$value;Test=$test}
}


Test-Boolean $true 'True boolean'
Test-Boolean 'true' 'True string'
Test-Boolean 1 '1 integer'
Test-Boolean $false 'False boolean'
Test-Boolean 'false' 'False string'
Test-Boolean 0 '0 integer'
Test-Boolean 'random' 'Any other string'
Test-Boolean 2 'Any other integer'
Test-Boolean ([string]::Empty) 'Empty string'
Test-Boolean ' ' 'Blank string'
Test-Boolean $null 'Null value'

After you run the snippet you should see results like the one below showing you how the two different If/Else statements evaluated the different values.

  |  |  
Average a list of numbers
$sum = $NumberArray | Measure-Object -Average
$sum.Average

Details

Use to get the sum of a number array


Example

PS C:\> $NumberArray = 10,23,24,43,118,23,43
>> $sum = $NumberArray | Measure-Object -Average
>> $sum.Average

40.5714285714286

  |  
Convert Between Time Zones
$DateTime = [DateTime]::SpecifyKind($date, [DateTimeKind]::Unspecified)
$from = [System.TimeZoneInfo]::FindSystemTimeZoneById($FromTimeZone)
$to = [System.TimeZoneInfo]::FindSystemTimeZoneById($ToTimeZone)
$utc = [System.TimeZoneInfo]::ConvertTimeToUtc($DateTime, $from)
[System.TimeZoneInfo]::ConvertTime($utc, $to)

Details

Convert from one Time Zone to another.


Example

PS C:\> $Date = Get-Date '3/28/2019 10:35 AM'
>> $FromTimeZone = 'Central Standard Time'
>> $ToTimeZone = 'US Mountain Standard Time'
>> $DateTime = [DateTime]::SpecifyKind($date, [DateTimeKind]::Unspecified)
>> $from = [System.TimeZoneInfo]::FindSystemTimeZoneById($FromTimeZone)
>> $to = [System.TimeZoneInfo]::FindSystemTimeZoneById($ToTimeZone)
>> $utc = [System.TimeZoneInfo]::ConvertTimeToUtc($DateTime, $from)
>> [System.TimeZoneInfo]::ConvertTime($utc, $to)


Thursday, March 28, 2019 8:35:00 AM

Convert From Unix Time
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($UnixTime))

Example

PS C:\> $UnixTime = '1553353149'
>> [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($UnixTime))


Saturday, March 23, 2019 9:59:09 AM

  |  |  
Convert From WMI Datetime
[Management.ManagementDateTimeConverter]::ToDateTime($WMIDate)

Details

When using the Get-WmiObject cmdlet datetimes are returned using the Common Information Model (CIM) format. This command will convert these to standard datetime objects.


Example

PS C:\> $WMIDate = (Get-WmiObject -Class Win32_OperatingSystem).LastBootUpTime
>> [Management.ManagementDateTimeConverter]::ToDateTime($WMIDate)


Tuesday, April 9, 2019 12:54:35 PM

Convert To Unix Time
[int][double]::Parse((Get-Date ($date).touniversaltime() -UFormat %s))

Example

PS C:\> $Date = Get-Date
>> [int][double]::Parse((Get-Date ($date).touniversaltime() -UFormat %s))

1553789149

  |  |  
Convert to UTC
$date.ToUniversalTime()

Example

PS C:\> $Date = Get-Date
>> $date.ToUniversalTime()


Thursday, March 28, 2019 4:05:51 PM

  
Copy Your Profile from ISE to Visual Studio Code
# Get the path to the Profile files
$ISEProfile = Join-Path (Split-Path $profile) "Microsoft.PowerShellISE_profile.ps1"
$VSCProfile = Join-Path (Split-Path $profile) "Microsoft.VSCode_profile.ps1"

# If the ISE Profile exists write the content to the VSCode Profile
if(Test-Path $ISEProfile){
    # Check if profile exists, create if it does not
    if(!(Test-Path $VSCProfile)){
        New-Item $VSCProfile -ItemType file -Force
    }
    # write content to VSCode Profile
    "`n# Copied from ISE Profile" | Out-File -FilePath $VSCProfile -Append
    Get-Content $ISEProfile | Out-File -FilePath $VSCProfile -Append
    "# End Copied from ISE Profile " | Out-File -FilePath $VSCProfile -Append
}

Details

Ready to move to VSCode, and want to migrate your profile from ISE. This script will take the entries from ISE and copy them to the VSCode profile.

  |  
Current Time Zone
[System.TimeZoneInfo]::Local

Example

PS C:\> $Date = Get-Date
>> [System.TimeZoneInfo]::Local



Id                         : Central Standard Time
DisplayName                : (UTC-06:00) Central Time (US & Canada)
StandardName               : Central Standard Time
DaylightName               : Central Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True


DateTime to Day Abbreviation
(Get-Culture).DateTimeFormat.GetAbbreviatedDayName($date.DayOfWeek.value__)

Details

Format a DateTime value in the Day Abbreviation format


Example

PS C:\> $Date = Get-Date
>> (Get-Culture).DateTimeFormat.GetAbbreviatedDayName($date.DayOfWeek.value__)

Thu

DateTime to ISO8601
$offset = ([System.TimeZoneInfo]::Local).BaseUtcOffset.ToString()
$offset = $offset.Substring(0,$offset.LastIndexOf(':'))
$date.ToString("yyyy-MM-ddTHH:mm:ss.fff") + $offset

Details

Format a DateTime value in the ISO8601 format


Example

PS C:\> $Date = Get-Date
>> $offset = ([System.TimeZoneInfo]::Local).BaseUtcOffset.ToString()
>> $offset = $offset.Substring(0,$offset.LastIndexOf(':'))
>> $date.ToString("yyyy-MM-ddTHH:mm:ss.fff") + $offset

2019-03-28T11:06:01.608-06:00

DateTime to ISO8601UTC
$date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") 

Details

Format a DateTime value in the ISO8601UTC format


Example

PS C:\> $Date = Get-Date
>> $date.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ")

2019-03-28T16:06:00.050Z

DateTime to LongDate
Get-Date $date -Format D

Details

Format a DateTime value in the LongDate format


Example

PS C:\> $Date = Get-Date
>> Get-Date $date -Format D

Thursday, March 28, 2019

DateTime to Month Abbreviation
(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($date.Month)

Details

Format a DateTime value in the Month Abbreviation format


Example

PS C:\> $Date = Get-Date
>> (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($date.Month)

Mar

DateTime to Month Name
(Get-Culture).DateTimeFormat.GetMonthName($date.Month)

Details

Format a DateTime value in the Month Name format


Example

PS C:\> $Date = Get-Date
>> (Get-Culture).DateTimeFormat.GetMonthName($date.Month)

March

DateTime to RFC1123UTC
Get-Date ($date.ToUniversalTime()) -Format r

Details

Format a DateTime value in the RF C1123UTC format


Example

PS C:\> $Date = Get-Date
>> Get-Date ($date.ToUniversalTime()) -Format r

Thu, 28 Mar 2019 16:05:56 GMT

DateTime to Round Trip
Get-Date $date -Format o

Details

Format a DateTime value in the Round Trip format


Example

PS C:\> $Date = Get-Date
>> Get-Date $date -Format o

2019-03-28T11:06:11.6293023-05:00

DateTime to SQL
$date.ToString("yyyy-MM-dd HH:mm:ss.fff")

Details

Format a DateTime value in the SQL format


Example

PS C:\> $Date = Get-Date
>> $date.ToString("yyyy-MM-dd HH:mm:ss.fff")

2019-03-28 11:05:58.440

DateTime to Year Quater
"$($date.Year)$("{0:00}" -f [Math]::ceiling($date.Month/3) )"

Details

Format a DateTime value in the Year Quater format


Example

PS C:\> $Date = Get-Date
>> "$($date.Year)$("{0:00}" -f [Math]::ceiling($date.Month/3) )"

201901

Display Profile Functions

If you are like me and have multiple machines you work on with different profiles, it can be difficult to remember which profile contains which functions. So, I wrote a quick function that will display all the functions for me on start up.

Just add the code below to the bottom of your $profile file.

Function Get-ProfileFunctions {
    $__ProfileFunctions = Get-Content $profile | Where-Object { $_.Trim() -match '^function' } | Foreach-Object {
        $_.Replace('{', ' ').Replace('(', ' ').Split()[1]
    }

    if ($__ProfileFunctions) {
        Write-Host "Profile functions loaded`n$('-' * 24)" -ForegroundColor Yellow
        $__ProfileFunctions | ForEach-Object { Write-Host " - $($_)" -ForegroundColor Yellow }
        Write-Host "`n"
    }
}
Get-ProfileFunctions

Now when you open PowerShell you will see a prompt like the one below showing you the functions you have in the profile file.

Profile functions loaded
------------------------
- MyCustom-Function1
- Get-ProfileFunctions

You can also run Get-ProfileFunctions at any time to show the functions again.

End of Month
(Get-Date $date.Date -day 1).AddMonths(1).AddMilliseconds(-1)

Example

PS C:\> $Date = Get-Date
>> (Get-Date $date.Date -day 1).AddMonths(1).AddMilliseconds(-1)


Sunday, March 31, 2019 11:59:59 PM

  
End of Week
$date.Date.AddDays(7-($date).DayOfWeek.value__).AddMilliseconds(-1)

Example

PS C:\> $Date = Get-Date
>> $date.Date.AddDays(7-($date).DayOfWeek.value__).AddMilliseconds(-1)


Saturday, March 30, 2019 11:59:59 PM

  
End Of Year
(Get-Date $date.Date -day 1 -Month 1).AddYears(1).AddMilliseconds(-1)

Example

PS C:\> $Date = Get-Date
>> (Get-Date $date.Date -day 1 -Month 1).AddYears(1).AddMilliseconds(-1)


Tuesday, December 31, 2019 11:59:59 PM

  
Find the Median Value
# sort array
$NumberArray = $NumberArray | Sort-Object
if ($NumberArray.count%2) {
    # if odd
    $medianvalue = $NumberArray[[math]::Floor($NumberArray.count/2)]
}
else {
    # if even
    $MedianValue = ($NumberArray[$NumberArray.Count/2],$NumberArray[$NumberArray.count/2-1] | Measure-Object -Average).average
}
$MedianValue

Details

Use this snippet to compute the median from an array of numerical values


Example

PS C:\> $NumberArray = 1,2,3,4,5
>> $NumberArray = $NumberArray | Sort-Object
>> if ($NumberArray.count%2) {
>>     # if odd
>>     $medianvalue = $NumberArray[[math]::Floor($NumberArray.count/2)]
>> }
>> else {
>>     # if even
>>     $MedianValue = ($NumberArray[$NumberArray.Count/2],$NumberArray[$NumberArray.count/2-1] | Measure-Object -Average).average
>> }
>> $MedianValue

3

  |  
Find the Mode Value
# Get the number of occurrences for each number
$numberCount = $NumberArray | Group-Object | Sort-Object -Descending count

# check that it is possble to calculate a mode
if(@($numberCount | Select-Object Count -Unique).Count -gt 1){

    # Get the count for the numbers with the most occurrences
    $topCount = ($numberCount | Select-Object -First 1).Count

    # Get the most frequently occurring values 
    $modevalue = ($numberCount | Where-Object{$_.Count -eq $topCount}).Name
}
$modevalue

Details

Use this snippet to compute the mode from an array of numerical values


Example

PS C:\> $NumberArray = 10,23,24,43,118,23
>> $numberCount = $NumberArray | Group-Object | Sort-Object -Descending count
>> if(@($numberCount | Select-Object Count -Unique).Count -gt 1){
>>     # Get the count for the numbers with the most occurrences
>>     $topCount = ($numberCount | Select-Object -First 1).Count
>>     # Get the most frequently occurring values
>>     $modevalue = ($numberCount | Where-Object{$_.Count -eq $topCount}).Name
>> }
>> $modevalue

23

  |  
First Day Of Month
Get-Date $date.Date -day 1

Example

PS C:\> $Date = Get-Date
>> Get-Date $date.Date -day 1


Friday, March 1, 2019 12:00:00 AM

  
First Day Of Week
$date.Date.AddDays(-($date).DayOfWeek.value__)

Example

PS C:\> $Date = Get-Date
>> $date.Date.AddDays(-($date).DayOfWeek.value__)


Sunday, March 24, 2019 12:00:00 AM

  
First Day Of Year
Get-Date $date.Date -day 1 -Month 1

Example

PS C:\> $Date = Get-Date
>> Get-Date $date.Date -day 1 -Month 1


Tuesday, January 1, 2019 12:00:00 AM

  
First Weekday of Month
# Get first day of Month
$FirstWeekDay = Get-Date $date.Date -day 1
# if day is Sat or Sun add days until it is not
while(0,6 -contains $FirstWeekDay.DayOfWeek.value__){
    $FirstWeekDay = $FirstWeekDay.AddDays(1)
}
$FirstWeekDay

Details

Returns the first weekday of the month for any given date.


Example

PS C:\> $date = Get-Date '6/1/2019'
>> $FirstWeekDay = Get-Date $date.Date -day 1
>> while(0,6 -contains $FirstWeekDay.DayOfWeek.value__){
>>     $FirstWeekDay = $FirstWeekDay.AddDays(1)
>> }
>> $FirstWeekDay


Monday, June 3, 2019 12:00:00 AM

  
Generate a Guid
[guid]::NewGUID()

Details

Generate a new Guid


Example

PS C:\> [guid]::NewGUID()


Guid
----
19587ae6-b148-4258-89fa-09e240afeb69

  
Generate Random Names
Function Get-RandomNames{
    [CmdletBinding()]
    [OutputType([Object])]
    param(
        [Parameter(Mandatory=$false)]
		[int] $count=10
    )
    
    $Webfemale = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-female-first.txt"
    $Webmale = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-male-first.txt"
    $WebSurname = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-surnames.txt"

    $female = @()
    $female = $Webfemale.Content.Split("`n").Trim() | ?{$_.length -gt 2} 

    $male = @()
    $male = $Webmale.Content.Split("`n").Trim() | ?{$_.length -gt 2} 

    $Surname = @()
    $Surname = $WebSurname.Content.Split("`n").Trim() | ?{$_.length -gt 2} 

    $names = @()
    for($i=0; $i -ne $count; $i++)
    {
        if(($i % 2) -eq 1)
        {
        $names += New-Object PSObject -Property @{Given=$($male | Get-Random);
                                                    Middle=$($male | Get-Random);
                                                    Surname=$($Surname | Get-Random)}
        }
        else
        {
        $names += New-Object PSObject -Property @{Given=$($female | Get-Random);
                                                    Middle=$($female | Get-Random);
                                                    Surname=$($Surname | Get-Random)}
        }
    }

    Return $names
}

Details

Pulls a list of all popular male and female names from the last 50 years and the 500 most common last names, and combines them to create a PowerShell object with a list of randomly generated names.


Example

PS C:\> Function Get-RandomNames{
>>     [CmdletBinding()]
>>     [OutputType([Object])]
>>     param(
>>         [Parameter(Mandatory=$false)]
>> 		[int] $count=10
>>     )
>>     $Webfemale = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-female-first.txt"
>>     $Webmale = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-male-first.txt"
>>     $WebSurname = Invoke-WebRequest "https://raw.githubusercontent.com/mdowst/RandomDataLookups/master/People/popular-surnames.txt"
>>     $female = @()
>>     $female = $Webfemale.Content.Split("`n").Trim() | ?{$_.length -gt 2}
>>     $male = @()
>>     $male = $Webmale.Content.Split("`n").Trim() | ?{$_.length -gt 2}
>>     $Surname = @()
>>     $Surname = $WebSurname.Content.Split("`n").Trim() | ?{$_.length -gt 2}
>>     $names = @()
>>     for($i=0; $i -ne $count; $i++)
>>     {
>>         if(($i % 2) -eq 1)
>>         {
>>         $names += New-Object PSObject -Property @{Given=$($male | Get-Random);
>>                                                     Middle=$($male | Get-Random);
>>                                                     Surname=$($Surname | Get-Random)}
>>         }
>>         else
>>         {
>>         $names += New-Object PSObject -Property @{Given=$($female | Get-Random);
>>                                                     Middle=$($female | Get-Random);
>>                                                     Surname=$($Surname | Get-Random)}
>>         }
>>     }
>>     Return $names
>> }
>> Get-RandomNames


Given   Middle   Surname
-----   ------   -------
Sofia   Renee    Luna
Douglas Camden   Klein
Tara    Kristi   Frazier
Johnny  Cory     Floyd
Lucy    Kendra   Sullivan
Colby   Chase    Holmes
Nora    Shelly   Hansen
Blake   Shannon  Williams
Holly   Penelope Mitchell
Grayson Ezra     Hampton

  |  
Get PowerShell Version
$PSVersionTable.PSVersion

Details

Returns the current version of PowerShell running.


Example

PS C:\> $PSVersionTable.PSVersion


Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      14393  0

  
Homework – Double Digit Addition without Carrying
My son decided to pretend to be sick from school the other day, so after we finished all the work the teach gave us, I decided to make him some extra work. This code will generate a page with 25 double digit addition problems. They haven’t learn to carry over digits yet, so all sums are less than 10. Maybe someone else out there could get some benefits from it.
[System.Collections.Generic.List[PSObject]] $page = @()
$j = 0
$blank52 = "<td height=""52""> </td>`n" * 9
$blank20 = "<td height=""20""><br></td>`n" * 9
while($j -lt 5){
    [System.Collections.Generic.List[PSObject]] $rowA = @()
    [System.Collections.Generic.List[PSObject]] $rowB = @()
    $i=0
    while($i -lt 5){
        $a = Get-Random -Minimum 1 -Maximum 10
        $b = Get-Random -Minimum 0 -Maximum (9-$a+1)

        $c = Get-Random -Minimum 1 -Maximum 10
        $d = Get-Random -Minimum 0 -Maximum (9-$c+1)

        if(($b + $d) -gt 0){
            if($b -eq 0){$b=' '}
            $rowA.Add("<td class=""xl66"" height=""52"" width=""115"">$a$c</td>`n")
            $rowB.Add("<td class=""xl65"" height=""52"" width=""115"">+ $b$d</td>`n")
            $i++
        }
    }

    $tableRows = New-Object System.Text.StringBuilder
    $tableRows.Append('<tr height="52">') | Out-Null
    $tableRows.Append($rowA -join('<td class="xl66" width="15"><br>')) | Out-Null
    $tableRows.Append('</tr><tr height="52">') | Out-Null
    $tableRows.Append($rowB -join('<td class="xl66" width="15"><br>')) | Out-Null
    $tableRows.Append("</tr><tr height=""52"">$blank52</tr>") | Out-Null
    $page.Add($tableRows.ToString())
    $j++
}


$bodyTop = @'
<html><head><title>math</title><style>.xl65{mso-style-parent:style0;font-size:36.0pt;mso-number-format:"\@";
text-align:right;border-top:none;border-right:none;border-bottom:1.5pt solid windowtext;border-left:none;}
.xl66{mso-style-parent:style0;font-size:36.0pt;mso-number-format:"\@";text-align:right;}</style></head><body>
<table style="text-align: left; width: 635px; height: 60px;" border="0" cellpadding="0" cellspacing="0"><tbody>
'@

$bodyBotton = @'
</tbody></table><br><br></body></html>
'@

$bodyTop + $page -join("<tr height=""20"">$blank20</tr>") + $bodyBotton | out-file '.\math.html'
  
If/Else Statement
# If $value equals 1 write True, else write False
if($value -eq 1){
    Write-Host "True"
} else {
    Write-Host "False"
}

Details

You can use the If statement to run code blocks if a specified conditional test evaluates to true.

  |  |  |  
If/ElseIf/Else Statement
# If $value equals 1 write True 1, else if it equals 2 write True 2, else write False
if($value -eq 1){
    Write-Host "True 1"
} elseif($value -eq 2){
    Write-Host "True 2"
} else {
    Write-Host "False"
}

Details

You can use the If statement to run code blocks if a specified conditional test evaluates to true. Use ElseIf to evaluate different scenarios

  |  |  |  
Input Box Pop-up
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$Value = [Microsoft.VisualBasic.Interaction]::InputBox("Enter a value", "Title", $null)

Details

Displays a pop-up box that prompts the user to enter a value. The value entered is then saved to a variable in the script.

  |  
Last Day of Month
(Get-Date $date.Date -day 1).AddMonths(1).AddDays(-1)

Example

PS C:\> $Date = Get-Date
>> (Get-Date $date.Date -day 1).AddMonths(1).AddDays(-1)


Sunday, March 31, 2019 12:00:00 AM

  
Last Day of Week
$date.Date.AddDays(6-($date).DayOfWeek.value__)

Example

PS C:\> $Date = Get-Date
>> $date.Date.AddDays(6-($date).DayOfWeek.value__)


Saturday, March 30, 2019 12:00:00 AM

  
Last Day Of Year
Get-Date $date.Date -day 31 -Month 12

Example

PS C:\> $Date = Get-Date
>> Get-Date $date.Date -day 31 -Month 12


Tuesday, December 31, 2019 12:00:00 AM

  
Last Weekday of Month
# Get last day of Month
$LastWeekDay = (Get-Date $date.Date -day 1).AddMonths(1).AddMilliseconds(-1)
# if day is Sat or Sun subtract days until it is not
while(0,6 -contains $LastWeekDay.DayOfWeek.value__){
    $LastWeekDay = $LastWeekDay.AddDays(-1)
}
$LastWeekDay

Details

Returns the last weekday of the month for any given date.


Example

PS C:\> $date = Get-Date '6/1/2019'
>> $LastWeekDay = (Get-Date $date.Date -day 1).AddMonths(1).AddMilliseconds(-1)
>> while(0,6 -contains $LastWeekDay.DayOfWeek.value__){
>>     $LastWeekDay = $LastWeekDay.AddDays(-1)
>> }
>> $LastWeekDay


Friday, June 28, 2019 11:59:59 PM

  
List All Time Zones
[System.TimeZoneInfo]::GetSystemTimeZones()

Details

Get a list of all Time Zones


Example

PS C:\> [System.TimeZoneInfo]::GetSystemTimeZones()



Id                         : Dateline Standard Time
DisplayName                : (UTC-12:00) International Date Line West
StandardName               : Dateline Standard Time
DaylightName               : Dateline Daylight Time
BaseUtcOffset              : -12:00:00
SupportsDaylightSavingTime : False

Id                         : UTC-11
DisplayName                : (UTC-11:00) Coordinated Universal Time-11
StandardName               : UTC-11
DaylightName               : UTC-11
BaseUtcOffset              : -11:00:00
SupportsDaylightSavingTime : False

Id                         : Aleutian Standard Time
DisplayName                : (UTC-10:00) Aleutian Islands
StandardName               : Aleutian Standard Time
DaylightName               : Aleutian Daylight Time
BaseUtcOffset              : -10:00:00
SupportsDaylightSavingTime : True

Id                         : Hawaiian Standard Time
DisplayName                : (UTC-10:00) Hawaii
StandardName               : Hawaiian Standard Time
DaylightName               : Hawaiian Daylight Time
BaseUtcOffset              : -10:00:00
SupportsDaylightSavingTime : False

Id                         : Marquesas Standard Time
DisplayName                : (UTC-09:30) Marquesas Islands
StandardName               : Marquesas Standard Time
DaylightName               : Marquesas Daylight Time
BaseUtcOffset              : -09:30:00
SupportsDaylightSavingTime : False

Id                         : Alaskan Standard Time
DisplayName                : (UTC-09:00) Alaska
StandardName               : Alaskan Standard Time
DaylightName               : Alaskan Daylight Time
BaseUtcOffset              : -09:00:00
SupportsDaylightSavingTime : True

Id                         : UTC-09
DisplayName                : (UTC-09:00) Coordinated Universal Time-09
StandardName               : UTC-09
DaylightName               : UTC-09
BaseUtcOffset              : -09:00:00
SupportsDaylightSavingTime : False

Id                         : Pacific Standard Time (Mexico)
DisplayName                : (UTC-08:00) Baja California
StandardName               : Pacific Standard Time (Mexico)
DaylightName               : Pacific Daylight Time (Mexico)
BaseUtcOffset              : -08:00:00
SupportsDaylightSavingTime : True

Id                         : UTC-08
DisplayName                : (UTC-08:00) Coordinated Universal Time-08
StandardName               : UTC-08
DaylightName               : UTC-08
BaseUtcOffset              : -08:00:00
SupportsDaylightSavingTime : False

Id                         : Pacific Standard Time
DisplayName                : (UTC-08:00) Pacific Time (US & Canada)
StandardName               : Pacific Standard Time
DaylightName               : Pacific Daylight Time
BaseUtcOffset              : -08:00:00
SupportsDaylightSavingTime : True

Id                         : US Mountain Standard Time
DisplayName                : (UTC-07:00) Arizona
StandardName               : US Mountain Standard Time
DaylightName               : US Mountain Daylight Time
BaseUtcOffset              : -07:00:00
SupportsDaylightSavingTime : False

Id                         : Mountain Standard Time (Mexico)
DisplayName                : (UTC-07:00) Chihuahua, La Paz, Mazatlan
StandardName               : Mountain Standard Time (Mexico)
DaylightName               : Mountain Daylight Time (Mexico)
BaseUtcOffset              : -07:00:00
SupportsDaylightSavingTime : True

Id                         : Mountain Standard Time
DisplayName                : (UTC-07:00) Mountain Time (US & Canada)
StandardName               : Mountain Standard Time
DaylightName               : Mountain Daylight Time
BaseUtcOffset              : -07:00:00
SupportsDaylightSavingTime : True

Id                         : Central America Standard Time
DisplayName                : (UTC-06:00) Central America
StandardName               : Central America Standard Time
DaylightName               : Central America Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : False

Id                         : Central Standard Time
DisplayName                : (UTC-06:00) Central Time (US & Canada)
StandardName               : Central Standard Time
DaylightName               : Central Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True

Id                         : Easter Island Standard Time
DisplayName                : (UTC-06:00) Easter Island
StandardName               : Easter Island Standard Time
DaylightName               : Easter Island Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True

Id                         : Central Standard Time (Mexico)
DisplayName                : (UTC-06:00) Guadalajara, Mexico City, Monterrey
StandardName               : Central Standard Time (Mexico)
DaylightName               : Central Daylight Time (Mexico)
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True

Id                         : Canada Central Standard Time
DisplayName                : (UTC-06:00) Saskatchewan
StandardName               : Canada Central Standard Time
DaylightName               : Canada Central Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : False

Id                         : SA Pacific Standard Time
DisplayName                : (UTC-05:00) Bogota, Lima, Quito, Rio Branco
StandardName               : SA Pacific Standard Time
DaylightName               : SA Pacific Daylight Time
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : False

Id                         : Eastern Standard Time (Mexico)
DisplayName                : (UTC-05:00) Chetumal
StandardName               : Eastern Standard Time (Mexico)
DaylightName               : Eastern Daylight Time (Mexico)
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : True

Id                         : Eastern Standard Time
DisplayName                : (UTC-05:00) Eastern Time (US & Canada)
StandardName               : Eastern Standard Time
DaylightName               : Eastern Daylight Time
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : True

Id                         : Haiti Standard Time
DisplayName                : (UTC-05:00) Haiti
StandardName               : Haiti Standard Time
DaylightName               : Haiti Daylight Time
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : True

Id                         : Cuba Standard Time
DisplayName                : (UTC-05:00) Havana
StandardName               : Cuba Standard Time
DaylightName               : Cuba Daylight Time
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : True

Id                         : US Eastern Standard Time
DisplayName                : (UTC-05:00) Indiana (East)
StandardName               : US Eastern Standard Time
DaylightName               : US Eastern Daylight Time
BaseUtcOffset              : -05:00:00
SupportsDaylightSavingTime : True

Id                         : Paraguay Standard Time
DisplayName                : (UTC-04:00) Asuncion
StandardName               : Paraguay Standard Time
DaylightName               : Paraguay Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Atlantic Standard Time
DisplayName                : (UTC-04:00) Atlantic Time (Canada)
StandardName               : Atlantic Standard Time
DaylightName               : Atlantic Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Venezuela Standard Time
DisplayName                : (UTC-04:00) Caracas
StandardName               : Venezuela Standard Time
DaylightName               : Venezuela Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Central Brazilian Standard Time
DisplayName                : (UTC-04:00) Cuiaba
StandardName               : Central Brazilian Standard Time
DaylightName               : Central Brazilian Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : SA Western Standard Time
DisplayName                : (UTC-04:00) Georgetown, La Paz, Manaus, San Juan
StandardName               : SA Western Standard Time
DaylightName               : SA Western Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : False

Id                         : Pacific SA Standard Time
DisplayName                : (UTC-04:00) Santiago
StandardName               : Pacific SA Standard Time
DaylightName               : Pacific SA Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Turks And Caicos Standard Time
DisplayName                : (UTC-04:00) Turks and Caicos
StandardName               : Turks and Caicos Standard Time
DaylightName               : Turks and Caicos Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Newfoundland Standard Time
DisplayName                : (UTC-03:30) Newfoundland
StandardName               : Newfoundland Standard Time
DaylightName               : Newfoundland Daylight Time
BaseUtcOffset              : -03:30:00
SupportsDaylightSavingTime : True

Id                         : Tocantins Standard Time
DisplayName                : (UTC-03:00) Araguaina
StandardName               : Tocantins Standard Time
DaylightName               : Tocantins Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : E. South America Standard Time
DisplayName                : (UTC-03:00) Brasilia
StandardName               : E. South America Standard Time
DaylightName               : E. South America Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : SA Eastern Standard Time
DisplayName                : (UTC-03:00) Cayenne, Fortaleza
StandardName               : SA Eastern Standard Time
DaylightName               : SA Eastern Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : False

Id                         : Argentina Standard Time
DisplayName                : (UTC-03:00) City of Buenos Aires
StandardName               : Argentina Standard Time
DaylightName               : Argentina Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : Greenland Standard Time
DisplayName                : (UTC-03:00) Greenland
StandardName               : Greenland Standard Time
DaylightName               : Greenland Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : Montevideo Standard Time
DisplayName                : (UTC-03:00) Montevideo
StandardName               : Montevideo Standard Time
DaylightName               : Montevideo Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : Saint Pierre Standard Time
DisplayName                : (UTC-03:00) Saint Pierre and Miquelon
StandardName               : Saint Pierre Standard Time
DaylightName               : Saint Pierre Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : Bahia Standard Time
DisplayName                : (UTC-03:00) Salvador
StandardName               : Bahia Standard Time
DaylightName               : Bahia Daylight Time
BaseUtcOffset              : -03:00:00
SupportsDaylightSavingTime : True

Id                         : UTC-02
DisplayName                : (UTC-02:00) Coordinated Universal Time-02
StandardName               : UTC-02
DaylightName               : UTC-02
BaseUtcOffset              : -02:00:00
SupportsDaylightSavingTime : False

Id                         : Mid-Atlantic Standard Time
DisplayName                : (UTC-02:00) Mid-Atlantic - Old
StandardName               : Mid-Atlantic Standard Time
DaylightName               : Mid-Atlantic Daylight Time
BaseUtcOffset              : -02:00:00
SupportsDaylightSavingTime : True

Id                         : Azores Standard Time
DisplayName                : (UTC-01:00) Azores
StandardName               : Azores Standard Time
DaylightName               : Azores Daylight Time
BaseUtcOffset              : -01:00:00
SupportsDaylightSavingTime : True

Id                         : Cape Verde Standard Time
DisplayName                : (UTC-01:00) Cabo Verde Is.
StandardName               : Cabo Verde Standard Time
DaylightName               : Cabo Verde Daylight Time
BaseUtcOffset              : -01:00:00
SupportsDaylightSavingTime : False

Id                         : UTC
DisplayName                : (UTC) Coordinated Universal Time
StandardName               : Coordinated Universal Time
DaylightName               : Coordinated Universal Time
BaseUtcOffset              : 00:00:00
SupportsDaylightSavingTime : False

Id                         : Morocco Standard Time
DisplayName                : (UTC+00:00) Casablanca
StandardName               : Morocco Standard Time
DaylightName               : Morocco Daylight Time
BaseUtcOffset              : 00:00:00
SupportsDaylightSavingTime : True

Id                         : GMT Standard Time
DisplayName                : (UTC+00:00) Dublin, Edinburgh, Lisbon, London
StandardName               : GMT Standard Time
DaylightName               : GMT Daylight Time
BaseUtcOffset              : 00:00:00
SupportsDaylightSavingTime : True

Id                         : Greenwich Standard Time
DisplayName                : (UTC+00:00) Monrovia, Reykjavik
StandardName               : Greenwich Standard Time
DaylightName               : Greenwich Daylight Time
BaseUtcOffset              : 00:00:00
SupportsDaylightSavingTime : False

Id                         : W. Europe Standard Time
DisplayName                : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
StandardName               : W. Europe Standard Time
DaylightName               : W. Europe Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : Central Europe Standard Time
DisplayName                : (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
StandardName               : Central Europe Standard Time
DaylightName               : Central Europe Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : Romance Standard Time
DisplayName                : (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
StandardName               : Romance Standard Time
DaylightName               : Romance Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : Central European Standard Time
DisplayName                : (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
StandardName               : Central European Standard Time
DaylightName               : Central European Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : W. Central Africa Standard Time
DisplayName                : (UTC+01:00) West Central Africa
StandardName               : W. Central Africa Standard Time
DaylightName               : W. Central Africa Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : False

Id                         : Namibia Standard Time
DisplayName                : (UTC+01:00) Windhoek
StandardName               : Namibia Standard Time
DaylightName               : Namibia Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : Jordan Standard Time
DisplayName                : (UTC+02:00) Amman
StandardName               : Jordan Standard Time
DaylightName               : Jordan Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : GTB Standard Time
DisplayName                : (UTC+02:00) Athens, Bucharest
StandardName               : GTB Standard Time
DaylightName               : GTB Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Middle East Standard Time
DisplayName                : (UTC+02:00) Beirut
StandardName               : Middle East Standard Time
DaylightName               : Middle East Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Egypt Standard Time
DisplayName                : (UTC+02:00) Cairo
StandardName               : Egypt Standard Time
DaylightName               : Egypt Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : E. Europe Standard Time
DisplayName                : (UTC+02:00) Chisinau
StandardName               : E. Europe Standard Time
DaylightName               : E. Europe Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Syria Standard Time
DisplayName                : (UTC+02:00) Damascus
StandardName               : Syria Standard Time
DaylightName               : Syria Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : West Bank Standard Time
DisplayName                : (UTC+02:00) Gaza, Hebron
StandardName               : West Bank Gaza Standard Time
DaylightName               : West Bank Gaza Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : South Africa Standard Time
DisplayName                : (UTC+02:00) Harare, Pretoria
StandardName               : South Africa Standard Time
DaylightName               : South Africa Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : False

Id                         : FLE Standard Time
DisplayName                : (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
StandardName               : FLE Standard Time
DaylightName               : FLE Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Turkey Standard Time
DisplayName                : (UTC+02:00) Istanbul
StandardName               : Turkey Standard Time
DaylightName               : Turkey Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Israel Standard Time
DisplayName                : (UTC+02:00) Jerusalem
StandardName               : Jerusalem Standard Time
DaylightName               : Jerusalem Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Kaliningrad Standard Time
DisplayName                : (UTC+02:00) Kaliningrad
StandardName               : Russia TZ 1 Standard Time
DaylightName               : Russia TZ 1 Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Libya Standard Time
DisplayName                : (UTC+02:00) Tripoli
StandardName               : Libya Standard Time
DaylightName               : Libya Daylight Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

Id                         : Arabic Standard Time
DisplayName                : (UTC+03:00) Baghdad
StandardName               : Arabic Standard Time
DaylightName               : Arabic Daylight Time
BaseUtcOffset              : 03:00:00
SupportsDaylightSavingTime : True

Id                         : Arab Standard Time
DisplayName                : (UTC+03:00) Kuwait, Riyadh
StandardName               : Arab Standard Time
DaylightName               : Arab Daylight Time
BaseUtcOffset              : 03:00:00
SupportsDaylightSavingTime : False

Id                         : Belarus Standard Time
DisplayName                : (UTC+03:00) Minsk
StandardName               : Belarus Standard Time
DaylightName               : Belarus Daylight Time
BaseUtcOffset              : 03:00:00
SupportsDaylightSavingTime : True

Id                         : Russian Standard Time
DisplayName                : (UTC+03:00) Moscow, St. Petersburg, Volgograd
StandardName               : Russia TZ 2 Standard Time
DaylightName               : Russia TZ 2 Daylight Time
BaseUtcOffset              : 03:00:00
SupportsDaylightSavingTime : True

Id                         : E. Africa Standard Time
DisplayName                : (UTC+03:00) Nairobi
StandardName               : E. Africa Standard Time
DaylightName               : E. Africa Daylight Time
BaseUtcOffset              : 03:00:00
SupportsDaylightSavingTime : False

Id                         : Iran Standard Time
DisplayName                : (UTC+03:30) Tehran
StandardName               : Iran Standard Time
DaylightName               : Iran Daylight Time
BaseUtcOffset              : 03:30:00
SupportsDaylightSavingTime : True

Id                         : Arabian Standard Time
DisplayName                : (UTC+04:00) Abu Dhabi, Muscat
StandardName               : Arabian Standard Time
DaylightName               : Arabian Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : False

Id                         : Astrakhan Standard Time
DisplayName                : (UTC+04:00) Astrakhan, Ulyanovsk
StandardName               : Astrakhan Standard Time
DaylightName               : Astrakhan Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : True

Id                         : Azerbaijan Standard Time
DisplayName                : (UTC+04:00) Baku
StandardName               : Azerbaijan Standard Time
DaylightName               : Azerbaijan Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : True

Id                         : Russia Time Zone 3
DisplayName                : (UTC+04:00) Izhevsk, Samara
StandardName               : Russia TZ 3 Standard Time
DaylightName               : Russia TZ 3 Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : True

Id                         : Mauritius Standard Time
DisplayName                : (UTC+04:00) Port Louis
StandardName               : Mauritius Standard Time
DaylightName               : Mauritius Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : True

Id                         : Georgian Standard Time
DisplayName                : (UTC+04:00) Tbilisi
StandardName               : Georgian Standard Time
DaylightName               : Georgian Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : False

Id                         : Caucasus Standard Time
DisplayName                : (UTC+04:00) Yerevan
StandardName               : Caucasus Standard Time
DaylightName               : Caucasus Daylight Time
BaseUtcOffset              : 04:00:00
SupportsDaylightSavingTime : True

Id                         : Afghanistan Standard Time
DisplayName                : (UTC+04:30) Kabul
StandardName               : Afghanistan Standard Time
DaylightName               : Afghanistan Daylight Time
BaseUtcOffset              : 04:30:00
SupportsDaylightSavingTime : False

Id                         : West Asia Standard Time
DisplayName                : (UTC+05:00) Ashgabat, Tashkent
StandardName               : West Asia Standard Time
DaylightName               : West Asia Daylight Time
BaseUtcOffset              : 05:00:00
SupportsDaylightSavingTime : False

Id                         : Ekaterinburg Standard Time
DisplayName                : (UTC+05:00) Ekaterinburg
StandardName               : Russia TZ 4 Standard Time
DaylightName               : Russia TZ 4 Daylight Time
BaseUtcOffset              : 05:00:00
SupportsDaylightSavingTime : True

Id                         : Pakistan Standard Time
DisplayName                : (UTC+05:00) Islamabad, Karachi
StandardName               : Pakistan Standard Time
DaylightName               : Pakistan Daylight Time
BaseUtcOffset              : 05:00:00
SupportsDaylightSavingTime : True

Id                         : India Standard Time
DisplayName                : (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
StandardName               : India Standard Time
DaylightName               : India Daylight Time
BaseUtcOffset              : 05:30:00
SupportsDaylightSavingTime : False

Id                         : Sri Lanka Standard Time
DisplayName                : (UTC+05:30) Sri Jayawardenepura
StandardName               : Sri Lanka Standard Time
DaylightName               : Sri Lanka Daylight Time
BaseUtcOffset              : 05:30:00
SupportsDaylightSavingTime : False

Id                         : Nepal Standard Time
DisplayName                : (UTC+05:45) Kathmandu
StandardName               : Nepal Standard Time
DaylightName               : Nepal Daylight Time
BaseUtcOffset              : 05:45:00
SupportsDaylightSavingTime : False

Id                         : Central Asia Standard Time
DisplayName                : (UTC+06:00) Astana
StandardName               : Central Asia Standard Time
DaylightName               : Central Asia Daylight Time
BaseUtcOffset              : 06:00:00
SupportsDaylightSavingTime : False

Id                         : Bangladesh Standard Time
DisplayName                : (UTC+06:00) Dhaka
StandardName               : Bangladesh Standard Time
DaylightName               : Bangladesh Daylight Time
BaseUtcOffset              : 06:00:00
SupportsDaylightSavingTime : True

Id                         : N. Central Asia Standard Time
DisplayName                : (UTC+06:00) Novosibirsk
StandardName               : Russia TZ 5 Standard Time
DaylightName               : Russia TZ 5 Daylight Time
BaseUtcOffset              : 06:00:00
SupportsDaylightSavingTime : True

Id                         : Myanmar Standard Time
DisplayName                : (UTC+06:30) Yangon (Rangoon)
StandardName               : Myanmar Standard Time
DaylightName               : Myanmar Daylight Time
BaseUtcOffset              : 06:30:00
SupportsDaylightSavingTime : False

Id                         : SE Asia Standard Time
DisplayName                : (UTC+07:00) Bangkok, Hanoi, Jakarta
StandardName               : SE Asia Standard Time
DaylightName               : SE Asia Daylight Time
BaseUtcOffset              : 07:00:00
SupportsDaylightSavingTime : False

Id                         : Altai Standard Time
DisplayName                : (UTC+07:00) Barnaul, Gorno-Altaysk
StandardName               : Altai Standard Time
DaylightName               : Altai Daylight Time
BaseUtcOffset              : 07:00:00
SupportsDaylightSavingTime : True

Id                         : W. Mongolia Standard Time
DisplayName                : (UTC+07:00) Hovd
StandardName               : W. Mongolia Standard Time
DaylightName               : W. Mongolia Daylight Time
BaseUtcOffset              : 07:00:00
SupportsDaylightSavingTime : True

Id                         : North Asia Standard Time
DisplayName                : (UTC+07:00) Krasnoyarsk
StandardName               : Russia TZ 6 Standard Time
DaylightName               : Russia TZ 6 Daylight Time
BaseUtcOffset              : 07:00:00
SupportsDaylightSavingTime : True

Id                         : Tomsk Standard Time
DisplayName                : (UTC+07:00) Tomsk
StandardName               : Tomsk Standard Time
DaylightName               : Tomsk Daylight Time
BaseUtcOffset              : 07:00:00
SupportsDaylightSavingTime : True

Id                         : China Standard Time
DisplayName                : (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
StandardName               : China Standard Time
DaylightName               : China Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : False

Id                         : North Asia East Standard Time
DisplayName                : (UTC+08:00) Irkutsk
StandardName               : Russia TZ 7 Standard Time
DaylightName               : Russia TZ 7 Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : True

Id                         : Singapore Standard Time
DisplayName                : (UTC+08:00) Kuala Lumpur, Singapore
StandardName               : Malay Peninsula Standard Time
DaylightName               : Malay Peninsula Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : False

Id                         : W. Australia Standard Time
DisplayName                : (UTC+08:00) Perth
StandardName               : W. Australia Standard Time
DaylightName               : W. Australia Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : True

Id                         : Taipei Standard Time
DisplayName                : (UTC+08:00) Taipei
StandardName               : Taipei Standard Time
DaylightName               : Taipei Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : False

Id                         : Ulaanbaatar Standard Time
DisplayName                : (UTC+08:00) Ulaanbaatar
StandardName               : Ulaanbaatar Standard Time
DaylightName               : Ulaanbaatar Daylight Time
BaseUtcOffset              : 08:00:00
SupportsDaylightSavingTime : True

Id                         : North Korea Standard Time
DisplayName                : (UTC+08:30) Pyongyang
StandardName               : North Korea Standard Time
DaylightName               : North Korea Daylight Time
BaseUtcOffset              : 08:30:00
SupportsDaylightSavingTime : True

Id                         : Aus Central W. Standard Time
DisplayName                : (UTC+08:45) Eucla
StandardName               : Aus Central W. Standard Time
DaylightName               : Aus Central W. Daylight Time
BaseUtcOffset              : 08:45:00
SupportsDaylightSavingTime : False

Id                         : Transbaikal Standard Time
DisplayName                : (UTC+09:00) Chita
StandardName               : Transbaikal Standard Time
DaylightName               : Transbaikal Daylight Time
BaseUtcOffset              : 09:00:00
SupportsDaylightSavingTime : True

Id                         : Tokyo Standard Time
DisplayName                : (UTC+09:00) Osaka, Sapporo, Tokyo
StandardName               : Tokyo Standard Time
DaylightName               : Tokyo Daylight Time
BaseUtcOffset              : 09:00:00
SupportsDaylightSavingTime : False

Id                         : Korea Standard Time
DisplayName                : (UTC+09:00) Seoul
StandardName               : Korea Standard Time
DaylightName               : Korea Daylight Time
BaseUtcOffset              : 09:00:00
SupportsDaylightSavingTime : False

Id                         : Yakutsk Standard Time
DisplayName                : (UTC+09:00) Yakutsk
StandardName               : Russia TZ 8 Standard Time
DaylightName               : Russia TZ 8 Daylight Time
BaseUtcOffset              : 09:00:00
SupportsDaylightSavingTime : True

Id                         : Cen. Australia Standard Time
DisplayName                : (UTC+09:30) Adelaide
StandardName               : Cen. Australia Standard Time
DaylightName               : Cen. Australia Daylight Time
BaseUtcOffset              : 09:30:00
SupportsDaylightSavingTime : True

Id                         : AUS Central Standard Time
DisplayName                : (UTC+09:30) Darwin
StandardName               : AUS Central Standard Time
DaylightName               : AUS Central Daylight Time
BaseUtcOffset              : 09:30:00
SupportsDaylightSavingTime : False

Id                         : E. Australia Standard Time
DisplayName                : (UTC+10:00) Brisbane
StandardName               : E. Australia Standard Time
DaylightName               : E. Australia Daylight Time
BaseUtcOffset              : 10:00:00
SupportsDaylightSavingTime : False

Id                         : AUS Eastern Standard Time
DisplayName                : (UTC+10:00) Canberra, Melbourne, Sydney
StandardName               : AUS Eastern Standard Time
DaylightName               : AUS Eastern Daylight Time
BaseUtcOffset              : 10:00:00
SupportsDaylightSavingTime : True

Id                         : West Pacific Standard Time
DisplayName                : (UTC+10:00) Guam, Port Moresby
StandardName               : West Pacific Standard Time
DaylightName               : West Pacific Daylight Time
BaseUtcOffset              : 10:00:00
SupportsDaylightSavingTime : False

Id                         : Tasmania Standard Time
DisplayName                : (UTC+10:00) Hobart
StandardName               : Tasmania Standard Time
DaylightName               : Tasmania Daylight Time
BaseUtcOffset              : 10:00:00
SupportsDaylightSavingTime : True

Id                         : Vladivostok Standard Time
DisplayName                : (UTC+10:00) Vladivostok
StandardName               : Russia TZ 9 Standard Time
DaylightName               : Russia TZ 9 Daylight Time
BaseUtcOffset              : 10:00:00
SupportsDaylightSavingTime : True

Id                         : Lord Howe Standard Time
DisplayName                : (UTC+10:30) Lord Howe Island
StandardName               : Lord Howe Standard Time
DaylightName               : Lord Howe Daylight Time
BaseUtcOffset              : 10:30:00
SupportsDaylightSavingTime : True

Id                         : Bougainville Standard Time
DisplayName                : (UTC+11:00) Bougainville Island
StandardName               : Bougainville Standard Time
DaylightName               : Bougainville Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : True

Id                         : Russia Time Zone 10
DisplayName                : (UTC+11:00) Chokurdakh
StandardName               : Russia TZ 10 Standard Time
DaylightName               : Russia TZ 10 Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : True

Id                         : Magadan Standard Time
DisplayName                : (UTC+11:00) Magadan
StandardName               : Magadan Standard Time
DaylightName               : Magadan Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : True

Id                         : Norfolk Standard Time
DisplayName                : (UTC+11:00) Norfolk Island
StandardName               : Norfolk Standard Time
DaylightName               : Norfolk Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : True

Id                         : Sakhalin Standard Time
DisplayName                : (UTC+11:00) Sakhalin
StandardName               : Sakhalin Standard Time
DaylightName               : Sakhalin Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : True

Id                         : Central Pacific Standard Time
DisplayName                : (UTC+11:00) Solomon Is., New Caledonia
StandardName               : Central Pacific Standard Time
DaylightName               : Central Pacific Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : False

Id                         : Russia Time Zone 11
DisplayName                : (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky
StandardName               : Russia TZ 11 Standard Time
DaylightName               : Russia TZ 11 Daylight Time
BaseUtcOffset              : 12:00:00
SupportsDaylightSavingTime : True

Id                         : New Zealand Standard Time
DisplayName                : (UTC+12:00) Auckland, Wellington
StandardName               : New Zealand Standard Time
DaylightName               : New Zealand Daylight Time
BaseUtcOffset              : 12:00:00
SupportsDaylightSavingTime : True

Id                         : UTC+12
DisplayName                : (UTC+12:00) Coordinated Universal Time+12
StandardName               : UTC+12
DaylightName               : UTC+12
BaseUtcOffset              : 12:00:00
SupportsDaylightSavingTime : False

Id                         : Fiji Standard Time
DisplayName                : (UTC+12:00) Fiji
StandardName               : Fiji Standard Time
DaylightName               : Fiji Daylight Time
BaseUtcOffset              : 12:00:00
SupportsDaylightSavingTime : True

Id                         : Kamchatka Standard Time
DisplayName                : (UTC+12:00) Petropavlovsk-Kamchatsky - Old
StandardName               : Kamchatka Standard Time
DaylightName               : Kamchatka Daylight Time
BaseUtcOffset              : 12:00:00
SupportsDaylightSavingTime : True

Id                         : Chatham Islands Standard Time
DisplayName                : (UTC+12:45) Chatham Islands
StandardName               : Chatham Islands Standard Time
DaylightName               : Chatham Islands Daylight Time
BaseUtcOffset              : 12:45:00
SupportsDaylightSavingTime : True

Id                         : Tonga Standard Time
DisplayName                : (UTC+13:00) Nuku'alofa
StandardName               : Tonga Standard Time
DaylightName               : Tonga Daylight Time
BaseUtcOffset              : 13:00:00
SupportsDaylightSavingTime : False

Id                         : Samoa Standard Time
DisplayName                : (UTC+13:00) Samoa
StandardName               : Samoa Standard Time
DaylightName               : Samoa Daylight Time
BaseUtcOffset              : 13:00:00
SupportsDaylightSavingTime : True

Id                         : Line Islands Standard Time
DisplayName                : (UTC+14:00) Kiritimati Island
StandardName               : Line Islands Standard Time
DaylightName               : Line Islands Daylight Time
BaseUtcOffset              : 14:00:00
SupportsDaylightSavingTime : False


Make Your Computer Talk
Add-Type -AssemblyName System.Speech
$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer
$Speech.Speak("I'm sorry Dave, I'm afraid I can't do that")

Details

Use the built-in Speech Synthesizer to have PowerShell make your computer talk. Credit to u/urabusPenguin on r/PowerShell for the idea.

Maximun value from list of numbers
$sum = $NumberArray | Measure-Object -Maximum
$sum.Maximum

Details

Use to get the maximum value of a number array


Example

PS C:\> $NumberArray = 10,23,24,43,118,23,43
>> $sum = $NumberArray | Measure-Object -Maximum
>> $sum.Maximum

118

  |  
Minimum value from list of numbers
$sum = $NumberArray | Measure-Object -Minimum 
$sum.Minimum

Details

Use to get the minimum value of a number array


Example

PS C:\> $NumberArray = 10,23,24,43,118,23,43
>> $sum = $NumberArray | Measure-Object -Minimum
>> $sum.Minimum

10

  |  
Out-GridView for VS Code

Out-GridView is a great tool for quickly creating selection dialogs or displaying information that you sort. However, when using it in Visual Studio Code (VS Code), it tends to display the grid window behind the VS Code window. So, in an effort to prevent me from having to click my mouse one more time, I created the function Out-GridViewCode. This function uses all the parameters as the standard Out-GridView, just add some extra functionality to ensure the grid window is the active one. When using the Out-GridView it will automatically bring the grid windows to the front. If you use the -PassThru or -Wait parameters Out-GridView does not release control until the windows is closed. So, in this situation the function will minimize the VS Code window allowing the grid window to be displayed. Then once the grid window is closed, VS Code will restore itself.

Note: This is designed for use with PowerShell 5 and below. It does not provide a replacement for the lack of Out-GridView in PowerShell Core 6.0. That fix is coming in PowerShell 7.0.


Function Out-GridViewCode{
<#    
.SYNOPSIS
    Sends output to an interactive table in a separate window. With extended support to display Out-GridView as main window when using VS Code
    
.DESCRIPTION
    The Out-GridView cmdlet sends the output from a command to a grid view window where the output is displayed in an interactive table. However, when you use VS Code the window appears in the background. Running this wrapper will bring the window to the front. 
	
	Parameters remain the same as the orginal Out-GridView
    
.PARAMETER InputObject
        Accepts input for Out-GridView.
            
.PARAMETER Title 
        Specifies the text that appears in the title bar of the Out-GridView window.
        
.PARAMETER OutputMode 
        Send items from the interactive window down the pipeline as input to other commands. By default, this cmdlet does not generate any output. To send items from the interactive window down the pipeline, click to select the items and then click OK.
		
.PARAMETER PassThru
        Indicates that the cmdlet sends items from the interactive window down the pipeline as input to other commands. By default, this cmdlet does not generate any output. This parameter is equivalent to using the Multiple value of the OutputMode parameter.
        
.PARAMETER Wait
        Indicates that the cmdlet suppresses the command prompt and prevents Windows PowerShell from closing until the Out-GridView window is closed. By default, the command prompt returns when the Out-GridView window opens.
#>
    [CmdletBinding(DefaultParameterSetName = 'PassThru')]
    Param(
        [Parameter(ValueFromPipeline = $true)]
        [PSObject[]]$InputObject,
        
        [Parameter(Mandatory=$false)]
        [string]$Title,

        [Parameter(ParameterSetName = "Wait")]
        [switch]$Wait,
        
        [Parameter(ParameterSetName = "OutputMode")]
        [Microsoft.PowerShell.Commands.OutputModeOption]$OutputMode,
        
        [Parameter(ParameterSetName = "PassThru")]
        [switch]$PassThru
    )
    Begin{
        # Create output list object
        [System.Collections.Generic.List[PSObject]] $OutputObject = @()

        # Load windows control and get VS Code process infomation
        $sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
        Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
        $processes = Get-Process -Name Code,powershell

        # Build parameter object to splat later on
        $GridViewParams = @{}
        $PSBoundParameters.GetEnumerator() | Where-Object {$_.Key -ne 'InputObject'} | ForEach-Object{
            $GridViewParams.Add($_.Key,$_.Value)
        }
    }
    Process{
        # Load each item to the Output object. This is done to handle pipeline values
        $InputObject | ForEach-Object{ $OutputObject.Add($_) }
    }
    End{
        # if wait or passthru minimize VS Code window
        # since the process does not release we go ahead and minimize
        # VS code so the grid windows appears
        if($Wait -or $PassThru){
            foreach($proc in $processes){
                $hwnd = @($proc)[0].MainWindowHandle
                [Win32.NativeMethods]::ShowWindowAsync($hwnd, 2) | Out-Null
            }
        } 
        
        # display out-gridview
        $OutputObject | Out-GridView @GridViewParams

        # if wait or passthru restore VS Code window
        # else bring grid to the front
        if($Wait -or $PassThru){
            foreach($proc in $processes){
                $hwnd = @($proc)[0].MainWindowHandle
                [Win32.NativeMethods]::ShowWindowAsync($hwnd, 3) | Out-Null
            }
        } else {
            Get-Process -Name powershell | Where-Object {$_.MainWindowTitle.Trim() -eq '$OutputObject | Out-GridView @GridViewParams' -or
                $_.MainWindowTitle.Trim() -eq $title} | ForEach-Object{
                    $hwnd = @($_)[0].MainWindowHandle
                    [Win32.NativeMethods]::ShowWindowAsync($hwnd, 2) | Out-Null
                    [Win32.NativeMethods]::ShowWindowAsync($hwnd, 10) | Out-Null
                }
        }
    } 
}

PowerShell Timer with Alarm
Function Start-Timer {
    param(
    [Parameter(Mandatory=$true)]
    [int]$seconds,
    [Parameter(Mandatory=$false)]
    [switch]$alarm 
    )
    $a = $(Get-Date)
    For($i=1;$i -le $seconds;$i++){
        Write-Progress -Activity "$seconds Second Timer" -Status $i -PercentComplete $(($i/$seconds)*100) -id 1
        Start-Sleep -Seconds 1
    }

    if($alarm){
        For($i=1;$i -le 10;$i++){
            [console]::beep(500,300)
        }
    }
}

Details

Simply call the function with the number of seconds and the optional alarm switch. It will provide a countdown with a progress bar.

Quick and Easy Day of the Week Date Picker
$today = [datetime]::Today
$dates = @()
for($i = $today.AddDays(0).DayOfWeek.value__; $i -ge 0; $i--){
    $dates += $today.AddDays(-$i)
}
$date = $dates | Out-GridView -PassThru

Details

This snippet will return the days of the current week, and display the results using the Out-GridView for you to select the date you want.

  |  
Remove First Entry in Fixed Array

Here is a quick little trick for removing the first entry in a fixed size array. This can be used when you receive the error message: Exception calling “RemoveAt” with “1” argument(s): “Collection was of a fixed size.”

# Remove first entry
$array = $array[1..($array.Length-1)]


Example

PS C:\> $array = 1..5
>> Write-Host 'Initial Value'
>> $array
>> $array = $array[1..($array.Length-1)]
>> Write-Host 'After Value'
>> $array

Initial Value
1
2
3
4
5
After Value
2
3
4
5

  
Round Number to Two Decimal Places
[math]::Round($number,2)

Details

Round number to two decimal places. Change the number after the comma to round to different decimal place


Example

PS C:\> $number = 3.14285714285714
>> [math]::Round($number,2)

3.14

  |  
Round to the Nearest Half
[math]::Round($number * 2, [MidpointRounding]::AwayFromZero) / 2

Details

Round a number to the nearest half (.5).


Example

PS C:\> $number = 3.64285714285714
>> [math]::Round($number * 2, [MidpointRounding]::AwayFromZero) / 2

3.5

  
Search for a Time Zones
[System.TimeZoneInfo]::GetSystemTimeZones() | Where-Object{$_.DisplayName -like "*$($Name)*" -or $_.DaylightName -like "*$($Name)*" -or
                        $_.StandardName -like "*$($Name)*" -or $_.Id -like "*$($Name)*"}

Details

Get a list of all Time Zones and filter based on a string


Example

PS C:\> $Name = 'Central'
>> [System.TimeZoneInfo]::GetSystemTimeZones() | Where-Object{$_.DisplayName -like "*$($Name)*" -or $_.DaylightName -like "*$($Name)*" -or
>>                         $_.StandardName -like "*$($Name)*" -or $_.Id -like "*$($Name)*"}



Id                         : Central America Standard Time
DisplayName                : (UTC-06:00) Central America
StandardName               : Central America Standard Time
DaylightName               : Central America Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : False

Id                         : Central Standard Time
DisplayName                : (UTC-06:00) Central Time (US & Canada)
StandardName               : Central Standard Time
DaylightName               : Central Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True

Id                         : Central Standard Time (Mexico)
DisplayName                : (UTC-06:00) Guadalajara, Mexico City, Monterrey
StandardName               : Central Standard Time (Mexico)
DaylightName               : Central Daylight Time (Mexico)
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : True

Id                         : Canada Central Standard Time
DisplayName                : (UTC-06:00) Saskatchewan
StandardName               : Canada Central Standard Time
DaylightName               : Canada Central Daylight Time
BaseUtcOffset              : -06:00:00
SupportsDaylightSavingTime : False

Id                         : Central Brazilian Standard Time
DisplayName                : (UTC-04:00) Cuiaba
StandardName               : Central Brazilian Standard Time
DaylightName               : Central Brazilian Daylight Time
BaseUtcOffset              : -04:00:00
SupportsDaylightSavingTime : True

Id                         : Central Europe Standard Time
DisplayName                : (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
StandardName               : Central Europe Standard Time
DaylightName               : Central Europe Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : Central European Standard Time
DisplayName                : (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
StandardName               : Central European Standard Time
DaylightName               : Central European Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : True

Id                         : W. Central Africa Standard Time
DisplayName                : (UTC+01:00) West Central Africa
StandardName               : W. Central Africa Standard Time
DaylightName               : W. Central Africa Daylight Time
BaseUtcOffset              : 01:00:00
SupportsDaylightSavingTime : False

Id                         : Central Asia Standard Time
DisplayName                : (UTC+06:00) Astana
StandardName               : Central Asia Standard Time
DaylightName               : Central Asia Daylight Time
BaseUtcOffset              : 06:00:00
SupportsDaylightSavingTime : False

Id                         : N. Central Asia Standard Time
DisplayName                : (UTC+06:00) Novosibirsk
StandardName               : Russia TZ 5 Standard Time
DaylightName               : Russia TZ 5 Daylight Time
BaseUtcOffset              : 06:00:00
SupportsDaylightSavingTime : True

Id                         : Aus Central W. Standard Time
DisplayName                : (UTC+08:45) Eucla
StandardName               : Aus Central W. Standard Time
DaylightName               : Aus Central W. Daylight Time
BaseUtcOffset              : 08:45:00
SupportsDaylightSavingTime : False

Id                         : AUS Central Standard Time
DisplayName                : (UTC+09:30) Darwin
StandardName               : AUS Central Standard Time
DaylightName               : AUS Central Daylight Time
BaseUtcOffset              : 09:30:00
SupportsDaylightSavingTime : False

Id                         : Central Pacific Standard Time
DisplayName                : (UTC+11:00) Solomon Is., New Caledonia
StandardName               : Central Pacific Standard Time
DaylightName               : Central Pacific Daylight Time
BaseUtcOffset              : 11:00:00
SupportsDaylightSavingTime : False


Single object array
[System.Collections.ArrayList] $ArrStrings = @()
$ArrStrings.Add("string") | Out-Null

Details

Works well for strings and other data types

  |  
Sum a list of numbers
$sum = $NumberArray | Measure-Object -Sum
$sum.Sum

Details

Use to get the sum of a number array


Example

PS C:\> $NumberArray = 10,23,24,43,118,23,43
>> $sum = $NumberArray | Measure-Object -Sum
>> $sum.Sum

284

  |  
Switch Statement
switch ($value)
{
    1 {"It is one."}
    2 {"It is two."}
    3 {"It is three."}
    4 {"It is four."}
}

Details

To check multiple conditions, use a Switch statement. The Switch statement is equivalent to a series of If statements, but it is simpler. The Switch statement lists each condition and an optional action. If a condition obtains, the action is performed.


Example

PS C:\> $value = 3
>> switch ($value)
>> {
>>     1 {"It is one."}
>>     2 {"It is two."}
>>     3 {"It is three."}
>>     4 {"It is four."}
>> }

It is three.

  |  |  
Yes/No Prompt
$yes = new-Object System.Management.Automation.Host.ChoiceDescription "&Yes","help"
$no = new-Object System.Management.Automation.Host.ChoiceDescription "&No","help"
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
$answer = $host.ui.PromptForChoice("Prompt","Click yes to continue",$choices,0)

if($answer -eq 0){
    Write-Host "You clicked Yes"
}elseif($answer -eq 1){
    Write-Host "You clicked No"
}

Details

Creates a Yes/No prompt and provides an example of taking actions based on the answer selected.

  |  |