As promised at today’s UK VMUG, here is a collection of tools that improve my PowerShell development workflow.
Reset the password of a local vRA user principal with vRO
A question that I frequently see popping up is “How can I reset the password of local user in vRA?“. A while back I blogged about how to achive this with PowervRA and Set-vRAUserPrincipal. However that might not be applicable to every situation.
An alternative solution could be to use a vRO workflow. The workflow could then be presented as an XaaS blueprint and published to the catalog, enabling administrators to reset passwords via the UI.
Retrieving the email address of a vRA user principal via vRO
If you don’t have access to Active Directory via the vRO plugin retrieving information about a certain user can be tricky. Here is a quick example showing how to retrieve an email address from a vRA user principal with vRO. Obviously assuming that you have chosen to sync the attribute in your directory configuration.
Escaping URI Strings
Recently I’ve found myself doing a lot of API queries with PowerShell. I often have a URI with a lot of query parameters and escaping them manually can be cumbersome and time-consuming.
To make life easier, I have started to use [uri]::EscapeUriString(string stringToEscape). It takes one parameter, which is the string to escape. Here is an example to illustrate its usage:
To reverse an escaped string you can use [uri]::UnescapeDataString(string stringToUnescape).
Update – 05/04/2017
An interesting issue was raised on one of my community projects recently. A contributor pointed out that one of our functions did not work when you chose to filter by name and the string passed to the Name parameter contained an ampersand (&).
Get-vRABusinessGroup -Name "Hello & Hello"
The REST API query was using a $filter parameter to return results where the name property was equal to the string passed to the Name parameter of the function. For example:
$URI = "/identity/api/tenants/$($TenantId)/subtenants?`$filter=name%20eq%20'Hello & Hello'"
In this case you should use [uri]::EscapeDataString(string stringToEscape). This method will also escape special characters within a string. So & becomes %26 and allows the request to succeed.
PowervRO – vRealize Orchestrator PowerShell Toolkit
PowervRO aims to simplify interacting with vRO from the command line by providing a library of functions to help you do things like execute workflows and actions or import resources.
Release 1.0.0 includes 59 functions covering a number of services exposed by the API. Currently we support:
- Actions-service
- Category-service
- Packages-service
- Plugin-service
- Resource-service
- Service-descriptor-service
- User-service
- Workflow-run-service
- Workflow-service
If you would like to see support for something that isn’t listed above let us know over at Github or fork us and submit your own functions.