PublicIP.psm1

[CmdletBinding()]
param()
$scriptName = 'PublicIP'
Write-Verbose "[$scriptName] - Importing module"

#region - From [functions] - [public]
Write-Verbose "[$scriptName] - [functions] - [public] - Processing folder"

#region - From [functions] - [public] - [Get-PublicIP]
Write-Verbose "[$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-Verbose "[$scriptName] - [functions] - [public] - [Get-PublicIP] - Done"
#endregion - From [functions] - [public] - [Get-PublicIP]

Write-Verbose "[$scriptName] - [functions] - [public] - Done"
#endregion - From [functions] - [public]

#region - From [variables] - [private]
Write-Verbose "[$scriptName] - [variables] - [private] - Processing folder"

#region - From [variables] - [private] - [common]
Write-Verbose "[$scriptName] - [variables] - [private] - [common] - Importing"

$script:providerMap = @{
    MyIP   = 'https://api.myip.com/'
    IPInfo = 'https://ipinfo.io/json'
}

Write-Verbose "[$scriptName] - [variables] - [private] - [common] - Done"
#endregion - From [variables] - [private] - [common]

Write-Verbose "[$scriptName] - [variables] - [private] - Done"
#endregion - From [variables] - [private]


$exports = @{
    Alias    = '*'
    Cmdlet   = ''
    Function = 'Get-PublicIP'
}
Export-ModuleMember @exports