Functions/Utilities/Resolve-CdsApiUrl.ps1

<#
    .SYNOPSIS
    Retrieve API Url according to region.
#>

function Resolve-CdsApiUrl {
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [String]
        $Region
    )
    begin {  
        $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); 
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); 
    }    
    process {
        # https://docs.microsoft.com/fr-fr/powerapps/developer/common-data-service/online-management-api/get-started-online-management-api#service-url
        $apiByRegion = @{ };
        $apiByRegion["NorthAmerica"] = "https://admin.services.crm.dynamics.com";
        $apiByRegion["NorthAmerica2"] = "https://admin.services.crm9.dynamics.com";
        $apiByRegion["EMEA"] = "https://admin.services.crm4.dynamics.com";
        $apiByRegion["APAC"] = "https://admin.services.crm5.dynamics.com";
        $apiByRegion["Oceania"] = "https://admin.services.crm6.dynamics.com";
        $apiByRegion["JPN"] = "https://admin.services.crm7.dynamics.com";
        $apiByRegion["SouthAmerica"] = "https://admin.services.crm2.dynamics.com";
        $apiByRegion["IND"] = "https://admin.services.crm8.dynamics.com";
        $apiByRegion["CAN"] = "https://admin.services.crm3.dynamics.com";
        $apiByRegion["UK"] = "https://admin.services.crm11.dynamics.com";
        $apiByRegion["FRANCE"] = "https://admin.services.crm12.dynamics.com";

        if ($apiByRegion.Keys -notcontains $Region) {
            throw "Unknown region $Region!";
        }
        
        $apiByRegion[$Region];
    }
    end {
        $StopWatch.Stop();
        Trace-CdsFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch;
    }
}

Export-ModuleMember -Function Resolve-CdsApiUrl -Alias *;