PowerShell Example

App Portal 2020 R1

The following PowerShell script example demonstrates how to use App Portal web services.

#############################################################################################

##

## File name: ap_cancel_request.ps1

## Description: This script runs and finds a specific request in App Portal and then

##              cancels it

##

## Instructions:

##   1. Define the following two variables found the Define variable section

##           $serverName

##           $reqID

##   2. Save the script

##   3. Execute the script

##

##

# Define variables

$serverName = "<enter_app_portal_server_name>"

$URI = "http://$serverName/esd/api.asmx?WSDL"

$reqID = "<enter_request_id>"

$notify = $true

 

# Define Web Service

$WebService = New-WebServiceProxy -Uri $URI -UseDefaultCredential

 

# Get details of a specific request

$retRequests = $WebService.GetDetailsForExistingRequestsByRequestID($reqID)

 

foreach($apRequest in $retRequests){

 

    write-host About to cancel request with request ID $apRequest.dtRequestDetails.RequestID

    # Cancel a request

    $actionResult = $WebService.cancelRequest($reqID,$notify)

    if ($actionResult -eq "1") {

       Write-Host Action completed successully -ForegroundColor Green

    } else {

       Write-Host Action completed with error -ForegroundColor Red

    }

}