PublicIP.psm1

[CmdletBinding()]
param()
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath)
$script:PSModuleInfo = Test-ModuleManifest -Path "$PSScriptRoot\$baseName.psd1"
$script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ }
$scriptName = $script:PSModuleInfo.Name
Write-Debug "[$scriptName] - Importing module"
#region [functions] - [public]
Write-Debug "[$scriptName] - [functions] - [public] - Processing folder"
#region [functions] - [public] - [Get-PublicIP]
Write-Debug "[$scriptName] - [functions] - [public] - [Get-PublicIP] - Importing"
function Get-PublicIP {
    <#
        .SYNOPSIS
        Gets your public IP address.

        .DESCRIPTION
        Gets your public IP address. You can specify a provider to use by using the Provider parameter.

        .EXAMPLE
        Get-PublicIP

        .EXAMPLE
        Get-PublicIP -Provider MyIP
    #>

    [CmdletBinding()]
    param(
        # The provider to use to get the public IP address.
        [Parameter()]
        [ValidateScript({ $providerMap.Keys })]
        $Provider = 'IPInfo'
    )

    Invoke-RestMethod -Uri $providerMap[$Provider]
}
Write-Debug "[$scriptName] - [functions] - [public] - [Get-PublicIP] - Done"
#endregion [functions] - [public] - [Get-PublicIP]
Write-Debug "[$scriptName] - [functions] - [public] - Done"
#endregion [functions] - [public]
#region [variables] - [private]
Write-Debug "[$scriptName] - [variables] - [private] - Processing folder"
#region [variables] - [private] - [common]
Write-Debug "[$scriptName] - [variables] - [private] - [common] - Importing"
$script:providerMap = @{
    MyIP   = 'https://api.myip.com/'
    IPInfo = 'https://ipinfo.io/json'
}
Write-Debug "[$scriptName] - [variables] - [private] - [common] - Done"
#endregion [variables] - [private] - [common]
Write-Debug "[$scriptName] - [variables] - [private] - Done"
#endregion [variables] - [private]

#region Member exporter
$exports = @{
    Alias    = '*'
    Cmdlet   = ''
    Function = 'Get-PublicIP'
}
Export-ModuleMember @exports
#endregion Member exporter