Skip to content

Check-TimeZone

Checks the time zone

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
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.