Home > Blogs > VMware PowerCLI Blog

Using the entire API for vRealize Operations via PowerCLI

Previously we showed you how to use the useful cmdlets available with the PowerCLI vRealize Operations Manager (vR Ops) module, but as we also explained there are only a few cmdlets at the moment and anyone who knows vR Ops will know that there is a lot more functionality than is provided by those cmdlets.

But don’t worry, it is possible to access the entire vR Ops REST API!  PowerCLI gives us the ability to expand the capability of the module to perform many more tasks that aren’t available via the included cmdlets.

In this blog post, which is a continuation of my previous blog posts on the PowerCLI vR Ops module, I will explain how to access the entire vR Ops public REST API via PowerCLI.  Before I begin, it will be helpful to cover some basic information about the vR Ops REST API.

The API is available via the base URI of https://{vrops-IP}/suite-api and if you browse to this link the documentation is available.  For the most part, the API is pretty well documented with examples for usage including payloads for XML and JSON.  Below is a screenshot of the XML request body example for the performAction method.


Throughout this post I will refer to the API documentation for example content such as this.  So, if you are following along take some time to browse the API documentation and leave it open as I continue.

Another important topic to cover before I start is “extensionData” in PowerCLI.  For those unfamiliar, this is a property container that is used for information returned from a client API call that doesn’t have a corresponding object property in PowerShell.  For example, as in my previous post, I invoke the cmdlet Get-OMResource to retrieve a vR Ops resource object, the object properties includes “extensionData” that has a lot of interesting content.


ExtensionData is the key concept in accessing the vR Ops API via PowerCLI. 

I will use the customer requirement for adding and updating a resource property as a walk-through. This should give you a good, basic understanding of how to leverage PowerCLI for any automation or programmatic administration of vR Ops.

To being, when I create a connection to vR Ops using Connect-OMServer a global variable is stored, $global:defaultOMServers, which has an extensionData property.


By the way, the [0] is the index of the server connection, since you can have multiple.  To simply things for my purposes, I just assign the connection properties to a local variable. 


Note that the extensionData property refers to the vR Ops API.  This is where things get interesting! We can easily use the PowerShell Get-Member cmdlet or “gm” for short to explore the properties and methods in the extensionData property.


As you can see, there are a lot of methods available.  This is where it is handy to have the API documentation open, because you can get additional information about each of these methods there by searching for the method name.  For example, above there is a method CreateReport and I can find this in the API documentation by just using Ctrl-F in my browser.


Generally speaking, the methods you find in the extensionData of the server connection are “top level” URIs.  For example /api/resource is a top level URI but there are lower level URIs like /api/resource/{id}/properties that are not contained in the server connection list of methods.

To access those, you simply need to browse the underlying object (for example, a resource object) and view the method membership within that object’s ExtensionData.  I used a shortcut here, but basically the command I used drills down to a resource object to show the members.


Notice the AddProperties method is available here.  I will look that up in the documentation.


Before I continue, I will grab a resource for which I want to create a new property, a virtual machine running Windows server OS named “bmutil”


If I simply reference the method, I can get help on the usage via the OverloadDefinitions property.


The method requires a single input of type VMware.VimAutomation.VRops.Views.PropertyContents so I will create a new variable $contentprops of this type to investigate.


So the only property is the singular Propertycontent.  Now I will create a variable contentprop of type VMware.VimAutomation.VROps.Views.PropertyContent.


Hopefully, you aren’t confused by all of this!  It can be a little frustrating.  This is where the API documentation comes in handy because the input parameter is the XML payload you would send as the REST request body via HTTP.  As I mentioned before, the API documentation provides an example.


I like to refer to the sample XML body because it helps in understanding how to create the input in PowerCLI.  Visualizing this way helps put all of this into perspective.  In addition to this, you can find in the API documentation more detail on the various data models used by the API which can be helpful in figuring out exactly what is required and descriptions of the properties.  For example, you’ll find within the method’s documentation links to the data representations as shown below.


Now, this link actually navigates to <ns3:property-contents> (with an “s” just like the PowerCLI type above) which is a collection of <ns3:property-content> and that model is actually the one that explains what each of the key:value pairs in the payload are used for, the data type and whether or not it is a required field.


Using this information, I can now update the payload for the method.  I am going to
create a new property called “custom|testproperty” with a value of “Created by PowerCLI” and manually put in a timestamp value.  By the way, the timestamp value is a Unix epoch timestamp (i.e. number of seconds since January 1, 1970).

Now I will update the $contentprop variable with the required values.


Next I will update the $contentprops variable with $contentprop.


And I am ready to invoke the method to add this new property to my resource.  But before that, I want to show that the property is not there by invoking the resource method GetResourceProperties.


OK, here we go… invoke $resource.ExtensionData.AddProperties($contentprops)…


Success!  If I want to change the value of this property, I simply provide the same statkey property name with the new timestamp and value.  Here I will just reuse the $contentprop and $contentprops variables.


The PowerCLI module for vR Ops is fully capable of leveraging the entire vR Ops public API and I hope this blog post provided you with a solid understanding of usage and concepts to explore and implement your own use cases.  With this information you can easily create functions and community modules to open up more of the vR Ops functionality via PowerCLI and automate more of your infrastructure.

Dias_John_thumb1_thumbJohn Dias is a Staff Systems Engineer on VMware’s Solution Engineering and Technology team specializing in Cloud Management solutions.

John is a veteran IT professional with over 22 years of experience, most of that having been on the customer side running data center operations, data storage, virtual infrastructure and Unix environments for a major financial institution.

He normally blogs at storagegumbo.com and in his spare time he enjoys astronomy and astrophotography.

This entry was posted in vRealize Operations and tagged on by .
Alan Renouf

About Alan Renouf

Alan Renouf is a Product Line Manager at VMware focusing on API's, SDK's and CLI's, He is responsible for providing the architects and operators of private and public cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/PowerCLI a book author and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

43 thoughts on “Using the entire API for vRealize Operations via PowerCLI

  1. Matthew Graci

    What is the command syntax to execute the PushEvent RestAPI via PowerCli for a VM?


  2. James

    Great post. One thing I woud like to do is to create custom groups via PowerCLI or the API. Unfortunately it seems that’s not currently possible 🙁

    I want to create vSphere Virtual Machine Tags that contain application IDs and then create a dynamic group for each App ID so that it will automatically group VMs into the same application. I have tested it on a small scale by manually creating a few custom Groups in vROPS and it works but I need to create hundreds 🙁

    Any idea how his may be achieved?

    1. james

      correction, I did not realise this was possible via the internal APIs as I didn’t initially notice. Now got it working but not using powercli. I will certainly be having a plat with this after reading your post again. Thanks for sharing.

  3. Pingback: PowerCLI study guide – core concepts - The Crazy Consultant

  4. vikrant

    Great Article, you show how to access the entire vR Ops public rest API via PowerCLI .PowerCLI gives us the ability to expand the capability of the module to perform many more tasks that aren’t available via the included cmdlets The PowerCLI module for vR Ops is fully capable of leveraging the entire vR Ops public API . Now I completely understood the usage and concepts .With the help of this article I can easily create functions and community modules to open up more of the vR Ops functionality via PowerCLI and automate more of our infrastructure. Thanks for sharing . The way you explained each and everything is really great. Thanks once again .

  5. Chris Smith

    I would like to get the summary information (or recommended actions) for an alert using PowerCli. I have some specific requirements around generating a CSV file containing actions that need to be taken for VMs and I have not been able to find any sound way of doing it other than copy and paste from each different summary page. This is time consuming and I need to make this happen quickly for an upcoming maintenance window. How can I do this with the REST API?

  6. facebook

    Can I just now say exactly what a relief to seek out a person that actually knows what theyre discussing on the net. You certainly learn how to bring a challenge to light and make it important. More people must ought to see this and appreciate this side of the story. I cant believe youre less well-known when you definitely contain the gift. facebook

  7. FCPX effects

    We are told that the first three aliens have already been killed and that Four is on the run with his guardian to Paradise, Ohio. FCPX effects

  8. ed marshall jewelers

    Simply to follow up on the up-date of this topic on your web site and would really want to let you know how much I loved the time you took to write this beneficial post. Within the post, you actually spoke regarding how to actually handle this issue with all convenience. It would be my personal pleasure to collect some more concepts from your web-site and come as much as offer other folks what I learned from you. Many thanks for your usual terrific effort. ed marshall jewelers

  9. Ed Marshall Jewelers

    Thanks for this advice I has been exploring all Yahoo to discover it! Ed Marshall Jewelers

  10. haircut rochester michigan

    I have to show some thanks to you for rescuing me from this particular predicament. Because of surfing around through the world wide web and coming across concepts that were not powerful, I was thinking my entire life was done. Living without the solutions to the difficulties you’ve sorted out as a result of this posting is a serious case, as well as ones that would have adversely damaged my entire career if I hadn’t encountered your website. Your expertise and kindness in maneuvering everything was important. I don’t know what I would have done if I hadn’t encountered such a subject like this. I can also now look ahead to my future. Thanks for your time so much for this reliable and results-oriented guide. I will not think twice to refer the blog to any person who should have recommendations on this problem.

  11. Social Media Training

    I was rattling happy to find this site on bing, just what I was searching for : D likewise bookmarked . Social Media Training

  12. luxury lifestyle

    I would like to voice my gratitude for your kind-heartedness giving support to individuals that should have assistance with in this situation. Your real dedication to getting the solution along had become astonishingly helpful and has in most cases helped somebody much like me to get to their desired goals. Your new warm and friendly report signifies so much to me and additionally to my office workers. Thank you; from everyone of us. luxury lifestyle

  13. projector price in bd

    I believe that is among the most significant information for me. And i’m satisfied studying your article. But wanna observation on some normal things, The web site style is perfect, the articles is in point of fact excellent . Excellent task, cheers. projector price in bd

  14. Wedding Receptions Newcastle

    You have to rely on your self . That’s the secrets involving success. Wedding Receptions Newcastle

  15. youtube smm services

    That appears to be excellent however i am still not too sure that I like it. At any rate will look far more into it and decide personally! youtube smm services

  16. Zonnepanelen prijs

    i love bob dylan, he is one of the best singer songwriter:: Zonnepanelen prijs

  17. Travel with low fare 

    There are a handful of intriguing points on time in this post but I don’t know if I see these center to heart. There is certainly some validity but I’ll take hold opinion until I look into it further. Excellent post , thanks and that we want a lot more! Added onto FeedBurner likewise Travel with low fare 

  18. judi dadu online

    You seem to be very professional in the way you write.;.;’: judi dadu online

  19. psoriatic arthritis remedy

    I bookmared your site a couple of days ago coz your blog impresses me.;`~”- psoriatic arthritis remedy

  20. Sewa Bus Pariwisata Bandung

    I have figured out some important things through your blog post. One other subject I would like to talk about is that there are plenty of games in the marketplace designed specifically for preschool age kids. They contain pattern acceptance, colors, dogs, and designs. These generally focus on familiarization as opposed to memorization. This makes children and kids occupied without having the experience like they are studying. Thanks Sewa Bus Pariwisata Bandung

  21. Aroma Incense (1,400 month)

    Wow, this is very fun to learn. Have you ever considered marketing with articles to magazines? Aroma Incense (1,400 month)

  22. dumps with pin

    Currently it looks like Drupal is the top blogging platform out there right now. (from what I’ve read) Is that what you are using on your blog? dumps with pin

  23. home theater projector

    I Love LENKA and i always play her music on my iPod. her music is quite unique:: home theater projector

  24. Front Door

    Thank you that is very helpful for me, as a new site has been inundated with comments that seem OK at first glance but then get repeated with a slight change of wording. I have something concrete to go on now and will delete quite a lot of them. Front Door

  25. driving traffic

    This will be the proper weblog for hopes to learn about this topic. You are aware of so much its almost tough to argue along with you (not that I really would want…HaHa). You definitely put a brand new spin on the topic thats been discussed for some time. Excellent stuff, just excellent! driving traffic

  26. desert safari deals

    family vacations in a nice tropical country would be very very nice. desert safari deals

  27. http://www.flystaybingo.com

    I really glad to find this internet site on bing, just what I was searching for : D besides saved to my bookmarks . http://www.flystaybingo.com

  28. childhood trauma Huntington, NY

    Some truly nice and utilitarian information on this web site , likewise I think the design and style holds fantastic features. childhood trauma Huntington, NY

  29. brique réparation montréal

    I enjoy looking through and I conceive this website got some truly useful stuff on it! . brique réparation montréal

  30. broches dentaires montreal

    you have got a great blog here! do you want to make some invite posts in my blog? broches dentaires montreal

  31. edward

    its very nice site dear people you may visit this site

    digital door vievers

  32. edward

    Uğurlu ve ekibi, hayal ettiğiniz en doğal veya dramatik sonuçları elde etmek için birlikte çalışırken, her adımda ihtiyacınız olan desteği sunarak refahınızı arttırmaktan büyük gurur duymaktadır.
    göğüs büyütme ameliyatı

  33. edward

    Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.paper writer

  34. Sam Antwi

    This is a great post. VMWare is an excellent choice for a virtual desktop so I am glad their API has the potential to do many things. quotehunt

  35. edward

    Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.recensioniacquisti

  36. Readymix

    Bila anda memerlukan informasi mengenai peroduk yang kami tawarkan, kami memiliki informasi Harga Beton Cor

  37. itunesgifts

    iTunes Gifts and Cards 2020

    Find out which on-line shops or provider sell iTunes present playing cards for less than the actual face worth. They pay as much as ninety five% of the card balance for these on their Most well-liked Itunes Gift Card Offers Merchants Checklist. I’ve seen discounts between 5 and 25 %, which implies you get that same discount on the stuff you purchase from the iTunes Store, the App Retailer, and the Mac App Retailer.

    Instead of combing through the present card aisle for just the right iTunes denomination, you may soon be able to get certainly Free Itunes Codes List 2019 one of these newly launched variable present cards. Usually speaking, I like giving physical playing cards as items, however plenty of individuals ship digital cards as gifts, too.

  38. konya kepenk

    thanks a lot!

  39. Ankara Çilingir

    Very helpful!

  40. Keçiören Çilingir

    Thanks for posting!


    Friends, we hope you have understood the better process of the Kingroot application. And this has given you all the information about Kingroot. If you still have a problem downloading this app then the comment box has been taken for your convenience. In it, you can tell your family with us without any hesitation. We will help you in this regard.

  42. marrakech desert tours

    Great information! its hulp for my Marrakech desert tours company


Leave a Reply

Your email address will not be published. Required fields are marked *