#powershell Get List of Two-letter Country ISO 3166 Code (alpha-2), Currency, Language and more

#requires -version 3.0
################################################################################
# Copyright (c) 201x-2018 leedesmond.com
# All Rights Reserved. Use at your own risk and responsibility.
# Version 1.00
#
################################################################################
#
$AllCultures = [System.Globalization.CultureInfo]::
GetCultures(
[System.Globalization.CultureTypes]::
SpecificCultures) # !AllCultures

# $AllCultures | ft -AutoSize
# $AllCultures.Count

##### build table of data
$objs = @();
$AllCultures | % {
$dn = $_.DisplayName.Split(“(|)”);
$RegionInfo = New-Object System.Globalization.RegionInfo $PsItem.name;
$objs += [pscustomobject]@{
Name = $RegionInfo.Name;
EnglishName = $RegionInfo.EnglishName;
TwoLetterISORegionName = $RegionInfo.TwoLetterISORegionName;
GeoId = $RegionInfo.GeoId;
ISOCurrencySymbol = $RegionInfo.ISOCurrencySymbol;
CurrencySymbol = $RegionInfo.CurrencySymbol;
IsMetric = $RegionInfo.IsMetric;
LCID = $PsItem.LCID;
Lang = $dn[0].Trim();
Country = $dn[1].Trim();
}
};

# $objs | ft -au
# $objs.Count

# find out the number of countries which support each available language in Windows
$objs | group lang | sort count -desc

# get number of Windows supported languages per country
# NOTE: the resulting figures do not necessary map to the officially
# supported number of languages of that country
$objs | group country | sort count -desc

# check which country or countries support a particular language
$objs | ? lang -eq “French” | ft -au

##### get list of unique country names and ISO codes in Windows
$countries = $objs |
select -Unique -prop TwoLetterISORegionName,EnglishName | sort TwoLetterISORegionName

# NOTE: the resulting number of nations worldwide found in Windows
# is lower than formally listed per the United Nations
# $countries | ft -AutoSize
# $countries.count

##### filter out non-standard ISO codes e.g. 029 Caribbean
$countries1 = $countries | ? TwoLetterISORegionName -cmatch “^[A-Z]*$”

# $countries1 | ft -AutoSize
# $countries1.count

#REFERENCE
Country Codes – ISO 3166 (list)
# IATA Codes
# United Nations Member States

Bookmark the permalink.

Leave a Reply