functions/Private/Blocks/Start-MgaProcessCatchDefault.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Start-MgaProcessCatchDefault {
    param (
        $Api,
        $UpdateMgaUriApi,
        $Result,
        $Uri,
        $Throw
    )
    try {
        if ($Uri.count -eq 1) {        
            if (($Api -eq 'All') -and ($UpdateMgaUriApi.Api -eq 'v1.0')) {
                Write-Verbose "No results found for the v1.0 Api. Trying the beta Api..."
            }
            else {
                if ($Result.'@odata.nextLink') {
                    $Uri = $Result.'@odata.nextLink'
                }
                Trace-MgaCatch -Throw $Throw
            }
        }
        else {
            Trace-MgaCatch -Throw $Throw
        }
        return [PSCustomObject]@{
            Uri = $Uri
        }
    }
    catch {
        throw $_
    }
}