cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Flexera CharlesW
Flexera

How do you call the App Broker Web Service through PowerShell?

Many common tasks in App Broker can be performed by calling the Web Service API’s which are available. Common tasks include creating/configuring new catalog items, submitting/canceling requests, and approving/rejecting requests which require approval. The two main SOAP Web Services in App Broker are as follows:

http://[AppPortalServer]/ESD/API.asmx

http://[AppPortalServer]/ESD/ws/integration.asmx

Hitting either of these pages in a browser will show the API calls which are available, and also the input parameters for each.

While there are a number of ways to invoke the App Broker API calls, perhaps the most common is through the use of a PowerShell script. Fortunately, PowerShell makes this easy. The following is a very basic example of using PowerShell to create a new request for a catalog item:

$catalogID = 12
$targetDevice = "MyMachineName" $targetUser = "MyDomain\MyUserName" $requester = "MyDomain\MyRequesterName" $useApproval = $false $sendEmail = $false $uri = "http://sup-apfnmp-cw/esd/api.asmx" #Change to reflect App Broker server name. $WebService = New-WebServiceProxy -Uri $uri -UseDefaultCredential $requestID = $WebService.createRequest($catalogID, $targetDevice, $requester, $targetUser, $useApproval, $sendEmail, @()) echo $requestID

Note that in the above case, the switch -UseDefaultCredential indicates that the credentials for the user invoking the PowerShell script will be used to connect to the Web Service. If it is desirable to use a different account to connect to the Web Service, then the script could be modified as follows to use a specific account:

$catalogID = 12
$targetDevice = "MyMachineName"
$targetUser = "MyDomain\MyUserName"
$requester = "MyDomain\MyRequesterName"
$useApproval = $false
$sendEmail = $false
$uri = "http://sup-apfnmp-cw/esd/api.asmx"  #Change to reflect App Broker server name.

$username = "MyDomain\MyAccountName"
$password = "MyPassword" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$WebService = New-WebServiceProxy -Uri $uri -Credential $cred
$requestID = $WebService.createRequest($catalogID, $targetDevice, $requester, $targetUser, $useApproval, $sendEmail, @())
echo $requestID 

Note:  Before you can call the above Web Services, you must enable the API. This can be done by going to Settings -> Flexera Integration, and selecting "Enable App Portal API"

1 Reply
Moderator jdempsey Moderator
Moderator

Re: How do you call the App Broker Web Service through PowerShell?

Or if you plan to run the script interactively and prefer to prompt for credentials for a "Run As"-like behavior instead of hard-coding alternate credentials into your script, you can leverage the Get-Credential commandlet.

Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".
0 Kudos