Invoke-ConversionSummary.ps1

<#
.SYNOPSIS
    This script returns the summary of the converted MSIX installer.
 
.DESCRIPTION
    This script reads the conversion Id and invokes the summary MSIX REST API.
 
.PARAMETER ConversionId
    The Conversion Id is required.
 
.PARAMETER Env
    Optional parameter of the environment value.
 
.OUTPUTS
    The package status is shown for conversion Id provided.
#>


# Uncomment for debugging
# Set-PSDebug -Trace 2

function Invoke-ConversionSummary() {

    # Conversion Id as a mandatory input
    param (
        [Parameter(Mandatory, HelpMessage = "Please provide a valid conversion Id.", Position=0)]
        [ValidatePattern(
            "^([0-9A-Fa-f]{8}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{4}[-][0-9A-Fa-f]{12})$",
            ErrorMessage = "Conversion Id {0} is not valid."
        )]
        [string] $ConversionId,

        [Parameter(HelpMessage = "Optional Parameter: Please provide the environment value.")]
        [string]$Env
    )

    # Get Environment value
    if ( !$Env )
    {
       $Env = "msix"
    }
    $global:devRestEndPoint = $(Get-Content "$PSScriptRoot/config.json" | ConvertFrom-Json).$Env.url

    Write-Debug "The entered conversion Id is $ConversionId"

    Try
    {
        # REST API invocation
        Authenticate($Env)

        $restEndpoint = $global:devRestEndPoint + "summary/v1/msix/" + $ConversionId

        $header = @{
            authorization=$global:bearerToken
        }
        ConvertFrom-Json $([String]::new((Invoke-WebRequest -Uri $restEndpoint -Header $header -MaximumRedirection 1).Content)) | Format-Table

    }
    Catch
    {
        Register-Error($_)
    }
}