Doing REST API calls via Powershell is straight forward using the Invoke-RestMethod cmdlet. Using the examples from inkysea’s blogpost, I’ll be showing how to do this calls to vRA using Powershell.
To start off, we need to define the header
and the body payload
username = "account";
tenant = "vsphere.local"
After which, we define the URI/ vRA URL to pass the REST payload
We then invoke the Invoke-RestMethod cmdlet
- ConvertTo-Json was done in $body variable because the REST call expects a JSON payload
- We save the response to $token variable as we need the ID/ authentication
Once completed, you will receive the TOKEN ID that we will be using to issue additional commands via REST.
NOTE: this ID expires after 24 hours. If you want to change the duration, this can be controlled via the property identity.basic.token.lifetime.hours=N of the /etc/vcac/security.properties file.
Once we have the token, we re-add the TOKEN ID in the header payload
Store the URI for the catalog service
Invoke RestMethod cmdlet to get the Entitled Catalog item for the user
- -UseDefaultCredential is needed as i keep getting authorization error (for some weird reason) so I had to hardcode this part
- $reponse would contain all entitled resource for the particular user