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" }
If/Else Statement
# If $value equals 1 write True, else write False if($value -eq 1){ Write-Host "True" } else { Write-Host "False" }
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)
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)*"}
DateTime to Year Quater
"$($date.Year)$("{0:00}" -f [Math]::ceiling($date.Month/3) )"
DateTime to Month Abbreviation
(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName($date.Month)