-
-
Notifications
You must be signed in to change notification settings - Fork 546
Expand file tree
/
Copy pathcheck-time-zone.ps1
More file actions
executable file
·32 lines (31 loc) · 828 Bytes
/
check-time-zone.ps1
File metadata and controls
executable file
·32 lines (31 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<#
.SYNOPSIS
Checks the time zone
.DESCRIPTION
This PowerShell script queries the local time zone and prints it.
.EXAMPLE
PS> ./check-time-zone.ps1
✅ 3:27 PM West Europe Summer Time (UTC+01:00:00 +1h DST)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
[system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US"
$Time = $((Get-Date).ToShortTimeString())
$TZ = (Get-Timezone)
$offset = $TZ.BaseUtcOffset
if ($TZ.SupportsDaylightSavingTime) {
$TZName = $TZ.DaylightName
$DST=" +1h DST"
} else {
$TZName = $TZ.StandardName
$DST=""
}
Write-Host "✅ $Time $TZName (UTC+$($offset)$($DST))"
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}