Featured Post

Wrapping Workspace ONE Goodness Around Office 365 - A Quick And Dirty Recipe

This recipe will detail a federation of Office 365 with a cloud instance of Workspace ONE Access, the product formerly know as VMware Ide...

Sunday, February 21, 2016

Interacting With The App Volumes REST API Through PowerShell

In December of last year Chris Halstead created an App Volumes API reference that blew my mind. (Check it out here:VMware App Volumes API Reference) He walks you through executing App Volumes management functions remotely using it's REST API and Google Postman as a client. After replicating the process in my lab it felt natural to ask, "can I do this in PowerShell natively?" Well, I went kind of crazy figuring out how but finally had some success. It's all about leveraging the Invoke-RestMethod cmdlet. You can find info about it here: Invoke-RestMethod

The first order of business is to login into the API. This is how:

$body = @{
username = “justin"
password = “VMware1!”
}

Invoke-RestMethod -SessionVariable DaLogin -Method Post -Uri "http://appvolumes.lab.local/cv_api/sessions” -Body $body


So above, "justin" is my AD username and "VMware1!" is the password for that account. "Appvolumes.lab.local" is the name of my App Volumes server. Here's the output:


Using the -Session variable option when executing this cmdlet is key. It creates a web request session object you use to authenticate in subsequent commands. In the command above the web request session object is assigned to a variable called ‘DaLogin’. I can now leverage this variable going forward when making API calls. For example, I can obtain info about App Volumes users with the following command:

Invoke-RestMethod -WebSession $DaLogin -Method Get -Uri "http://appvolumes.lab.local/cv_api/users”



Or, I can obtain information about app stacks with this:

Invoke-RestMethod -WebSession $DaLogin -Method Get -Uri "http://appvolumes.lab.local/cv_api/appstacks”



And, since we're talking powershell, we can easily pin point specific pieces of info we're looking for.

Invoke-RestMethod -WebSession $DaLogin -Method Get -Uri "http://appvolumes.lab.local/cv_api/appstacks” | FT id, name, created_at


Now, using the id # gleamed for the last command I can go on to assign and attach an app stack to a user. Here's the command:

Invoke-RestMethod -WebSession $DaLogin -Method Post -Uri "http://appvolumes.lab.local/cv_api/assignments?action_type=Assign&id=1&assignments%5B0%5D%5Bentity_type%5D=User&assignments%5B0%5D%5Bpath%5D=CN%3Djustin%2CCN%3DUsers%2CDC%3Dlab%2CDC%3Dlocal&rtime=true&mount_prefix="




These are just a few examples of some of the shenanigans we can get into using PowerShell and the App Volumes REST API. For additional examples and details of different API calls you should definitely check out Mr. Halstead's blog.

3 comments:

  1. This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. Read more at MaddenMobileWithCoins.com

    ReplyDelete
  2. I admit, I have not been on this web page in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. professionals. I thank you to help making people more aware of possible issues. vice city for android

    ReplyDelete
  3. Die Aktivitäten von Kindern können auch mit dieser iPhone Spionage-Software verfolgt werden. iphoneorten Es ist die Technologie, die viele Aspekte unseres soziokulturellen und politischen Lebens auf beiden Seiten des Spektrums verändert hat.

    ReplyDelete