function Get-IANATimeZone {
      Returns the IANA Time Zone based on public IP address.
      There are two endpoints used to obtain the IANA Time Zone:
      - Get the public IP address of the host
      - Translate the public IP into an IANA time zone
      Returns the IANA time zone for the current host.
      Returns the IANA time zone for the IP address
      Specifies the IP address to get the IANA time zone for.
      IANA time zone, as a string

  param (
    [string]$IPAddress = (Invoke-WebRequest -Uri '' -ContentType 'text/plain').Content.Trim()
  Write-Verbose "Public IP: $IPAddress"

  try {
    $iana_tz = (Invoke-RestMethod -Method Get -Uri "$IPAddress").timezone
  catch {
    throw "Failed to get public IP address: $_"

  Write-Verbose "IANA Timezone: $iana_tz"

  return $iana_tz