Public/Get-MoveProvider.ps1

Function Get-MoveProvider {
    <#
    .SYNOPSIS
        List details of all migration providers
    .DESCRIPTION
 
    .NOTES
        Implements details in https://www.nutanix.dev/api_reference/apis/provider.html
    .LINK
        Specify a URI to a help page, this will show when Get-Help -Online is used.
    .EXAMPLE
        Get-MoveExampleSomething -Verbose
        Explanation of the function or its result. You can include multiple examples with additional .EXAMPLE lines
    #>


    [CmdletBinding(DefaultParameterSetName = 'ByID')]
    param(
        [Parameter(Mandatory = $false,
            HelpMessage = 'Move server or session name')][Alias('Server')][String]$MoveSession,
        [Parameter(Mandatory = $false,
            ParameterSetName = 'ByID',
            HelpMessage = 'Provider ID')][String]$Id,
        [Parameter(ParameterSetName = 'ListAvailable')][switch]$ListAvailable
    )

    ## Get Session Configuration
    $MoveSessionConfig = if ($MoveSession) { Get-MoveSession -Name $MoveSession } else { Get-MoveSession }

    #Honor SSL Settings
    if ($MoveSessionConfig.AllowInsecureSSL) {
        $MoveCertSettings = @{SkipCertificateCheck = $true }
    } else {
        $MoveCertSettings = @{SkipCertificateCheck = $false }
    }

    $uri = "https://$($MoveSessionConfig.MoveServer):$($MoveSessionConfig.MovePort)/move/v2/"
    switch ($PSCmdlet.ParameterSetName) {
        'ByID' {
            $uri += "providers/$($Id)"
        }

        'ListAvailable' {
            $uri += 'providers/list'
        }
    }

    try {
        $RestMethodSplat = @{
            Uri            = $uri
            TimeoutSec     = 100
            Method         = 'POST'
            WebSession     = $MoveSessionConfig.MoveWebSession
            ProgressAction = 'SilentlyContinue'
        }
        $Result = Invoke-RestMethod @RestMethodSplat @MoveCertSettings

    } catch {
        throw $_.Exception.Message
    }
    return $Result
}