Skip to content

Instantly share code, notes, and snippets.

@zenopopovici
Last active January 10, 2022 14:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save zenopopovici/c4a67ba6286930e4d10f0df3d8fa014b to your computer and use it in GitHub Desktop.
# STEP 3: Set time zone (if specified)
#if ($config.Config.TimeZone) {
# Write-Host “Setting time zone: $($config.Config.TimeZone)”
# Set-Timezone -Id $config.Config.TimeZone
#}
$BingMapsKey = 'AmI6Xs5u81T1Q8vbk_SXlwty7Mrw_AOb2EDfSdZcHWcR0b5qKV8zgGTDT84XyoX1'
$IPInfo = Invoke-RestMethod -Method 'Get' -Uri 'http://ipinfo.io/json'
$Location = $IPInfo.loc
Write-Host "Country : "$IPInfo.country
Write-Host "Public IP Address : "$IPInfo.ip
Write-Host "Location : "$IPInfo.loc
$BingTimeZoneURL = "http://dev.virtualearth.net/REST/v1/TimeZone/$Location" + "?key=$BingMapsKey"
$ResultTZ = Invoke-RestMethod -Method 'Get' -Uri $BingTimeZoneURL
$WindowsTZ = $ResultTZ.resourceSets.resources.timeZone.windowsTimeZoneId
If (-not [string]::IsNullOrEmpty($WindowsTZ)) {
    Get-TimeZone -Name $WindowsTZ
    Set-TimeZone -Name $WindowsTZ
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment