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.

clip_image002

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.

clip_image004

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.

clip_image006

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. 

clip_image008

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.

clip_image010

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.

clip_image012

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.

clip_image014

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

clip_image016

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”

clip_image018

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

clip_image020

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.

clip_image022

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

clip_image024

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.

clip_image026

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.

clip_image027

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.

clip_image029

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.

clip_image031

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

clip_image033

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.
 

clip_image035

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

clip_image037

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.

clip_image039

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.

96 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?

    Thanks,
    -Matt

    Reply
  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?

    Reply
    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.

      Reply
  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 .

    Reply
  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?

    Reply
  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

    Reply
  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

    Reply
  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

    Reply
  9. Ed Marshall Jewelers

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

    Reply
  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.

    Reply
  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

    Reply
  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

    Reply
  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

    Reply
  14. Wedding Receptions Newcastle

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

    Reply
  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

    Reply
  16. Zonnepanelen prijs

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

    Reply
  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 

    Reply
  18. judi dadu online

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

    Reply
  19. psoriatic arthritis remedy

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

    Reply
  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

    Reply
  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)

    Reply
  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

    Reply
  23. home theater projector

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

    Reply
  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

    Reply
  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

    Reply
  26. desert safari deals

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

    Reply
  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

    Reply
  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

    Reply
  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

    Reply
  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

    Reply
  31. onzie.com

    I’ve recently started a site, and the information you offer on this website has helped me a lot. Thank you for all of your time & work. onzie.com

    Reply
  32. nsf collections

    I simply couldn’t go away your blog before suggesting we really enjoyed the standard information someone give your visitors? Shall be back often to evaluate high on new posts nsf collections

    Reply
  33. Cold Stone Franchise

    I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. Cold Stone Franchise

    Reply
  34. Uddharan

    Great post very very thank you for your advice.

    Reply
  35. Zymak Bangladesh

    We have the best projectors and cheapest price. We have all kinds of projectors. 3D Projector , HD Projector, LED Projector, Multimedia Projector and Mini Projector. Check out our projector price in bangladesh

    Reply
  36. Web Design houston

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

    Web Design houston

    Reply
  37. Web Design houston

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


    Web Design houston

    Reply
  38. lizey

    Many thanks for the exciting blog posting! Simply put your blog post to my favorite blog list and will look forward for additional updates. Simply wanted to write down a word in order to say thanks to you for those wonderful tips.

    Sammamish garage doors

    Reply
  39. lizey

    Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!

    Seattle garage door service

    Reply
  40. lizey

    Many thanks for the exciting blog posting! Simply put your blog post to my favorite blog list and will look forward for additional updates. Simply wanted to write down a word in order to say thanks to you for those wonderful tips.!.

    The Woodlands garage door

    Reply
  41. lizey

    Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success.

    mark ramer and michael saperstein

    Reply
  42. lizey

    Tabrez Rubberwala Ankush Heights is the final destination for you. You can end your search for a perfect home here:

    Tabrez Rubberwala

    Reply
  43. lizey

    Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success.

    workout routine

    Reply
  44. lizey

    Thanks for the nice blog. It was very useful for me. I m happy I found this blog. Thank you for sharing with us,I too always learn something new from your post.,

    excercise for weight loss

    Reply
  45. lizey

    I have bookmarked your blog, the articles are way better than other similar blogs, thanks for a great share,!

    annabel law singapore

    Reply
  46. lizey

    My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!

    scs 718 static sensor

    Reply
  47. lizey

    Thanks so much for this post! Great wise words from the voice of experience like you! I have forwarded your website to my friends!

    seo

    Reply
  48. lizey

    My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!

    istanbul temizlik şirketleri

    Reply
  49. lizey

    I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.

    istanbul evden eve nakliyat

    Reply
  50. lizey

    I am thoroughly amazed at how you made this website, It’s really great talent.

    tesettür giyim

    Reply
  51. lizey

    My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!

    sleeping pills name

    Reply
  52. lizey

    I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.

    how to sleep better

    Reply
  53. lizey

    I am thoroughly amazed at how you made this website, It’s really great talent.

    Stroke

    Reply
  54. lizey

    Thanks a lot for the article.Thanks Again. Want more.,

    cardiovascular

    Reply
  55. lizey

    Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting.,

    invisalign

    Reply
  56. lizey

    I found this is an informative and interesting post so i think so it is very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this article.,

    invisalign

    Reply
  57. lizey

    Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors.,

    invisalign

    Reply
  58. lizey

    I am scanning for and I need to post a comment that “The substance of your post is grand” Great work.,

    invisalign

    Reply
  59. lizey

    What a post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much.

    invisalign paris

    Reply
  60. lizeykevin

    i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future..

    sourire

    Reply
  61. toner

    i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future..

    onlinetoner.bg

    Reply
  62. Lizaa

    Nice knowledge gaining article. This post is really the best on this valuable topic.,
    dalaman havalimanı transfer

    Reply
  63. Lizaa

    Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post. we need work out more techniques in this regard. thanks for sharing

    pest control

    Reply
  64. lizeyykkk

    This post is really interesting. Thanks for sharing such a nice post.,

    happy mothers day funny meme

    Reply
  65. LizEykevin12

    Amazing post you have published here. Thank you for this kind of great information. Also, get more information on:

    hair salons knoxville tn

    Reply
  66. Lizeykevin

    I think that thanks for the valuabe information and insights you have so provided here:

    Athletic tips

    Reply
  67. Lizeykevins

    Hi Admin,Great job. A very useful article, indeed!Great share!Heading off to share this right now!:

    child care staffing agency

    Reply
  68. lizyy

    Creativia est une agence de communication située à Genève
    agence communication genève

    Reply
  69. lizaey

    Great post, thanks for the awesome blog post. I’m having troubles subscribing to your blogs feed. Thought I’d let you know.,

    hair salon nyc

    Reply
  70. liazaeysss

    I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog.,

    salon halo

    Reply
  71. lizzy

    Great post, thanks for the awesome blog post. I’m having troubles subscribing to your blogs feed. Thought I’d let you know.,

    remington 5800 shaver

    Reply
  72. Kevin321

    Nice to read your article! I am looking forward to sharing your adventures and experiences.,

    Buy twitch followers

    Reply
  73. Seolizey21

    Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.,

    Famouz.io

    Reply
  74. Seolizaa

    This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information., 

    aptos facelift

    Reply
  75. Seolizzaa2

    The looks really great. Most of these smaller details are usually created employing wide range of heritage knowledge.,

    Android Rooting Tool

    Reply
  76. seo hizmeti

    good post, thanks

    Reply
  77. LizaseoK

    I would like to say that this blog really convinced me to do it! Thanks. very good post., 

    Black obsidian necklace

    Reply
  78. LizaseoKEvin

    Excellent post. I was reviewing this blog continuously, and I am impressed! Extremely helpful information especially this page., 

    Car Photography Retouching

    Reply
  79. KevinSs

    looking for the best heating system for apartments and don’t know what the best warming system is, then you will find this guide quite useful
    Best warming system

    Reply
  80. Seo1

    hi good day , thanky for best guide i book mark your web because is best information.,

    Iphone xr leather case

    Reply
  81. Seo23

    Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking., 

    mobile accessories wholesale

    Reply
  82. seolizak

    Great post, thanks for the awesome blog post. I’m having troubles subscribing to your blogs feed. Thought I’d let you know.,

    anonymouscheats

    Reply
  83. seolizakev

    This article is incredibly superb, the strategy for making is essentially astounding. Keep doing work like this the world needs increasingly powerful articles.,

    Postmates driver

    Reply
  84. seolizakevi

    This article is incredibly superb, the strategy for making is essentially astounding. Keep doing work like this the world needs increasingly powerful articles.,

    bandarq online terpercaya

    Reply
  85. seolizakevin

    Great survey, I’m sure you’re getting a great response.,

    agencia de marketing

    Reply
  86. seolizakevin987

    Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking.,

    boutique baby clothes brands

    Reply
  87. expertlizaa

    It was a very good post indeed. I thoroughly enjoyed reading it in my lunch time. Will surely come and visit this blog more often. Thanks for sharing.,

    power window repair west palm beach

    Reply
  88. expertlizaa22A

    Wow very awesome post you have top posted at this time.these kind of post are very useful for people at sometime.so i would like to say you thanks for sharing this nice post.,

    Jon Snow Game Of Thrones

    Reply
  89. Lizeyexpert321

    This post gives the light on a very important topic and provides in-depth knowledge. I want to say thanks for this kind of articles.,

    cbd hemp oil for pets

    Reply
  90. KExperts.3

    This post gives the light on a very important topic and provides in-depth knowledge. I want to say thanks for this kind of articles.,

    tks industrial

    Reply
  91. IAmSeoExpert

    Today, I was just browsing along and came upon your blog. Just wanted to say good blog and this article helped me a lot, due to which I have found exactly I was looking., 

    child counselling singapore

    Reply
  92. Theexpert1

    Why buy Blade & Soul Gold and Items from Joymmo.com shop? We provide a wide range of Blade and Soul Gold & Itmes for all servers in-game, such as NA Server, EU, DE, and FR Servers. Best advantages are lowest price, 100% legit, security trade, and fast delivery. 24/7/365 Live Chat online supported.

    blade and soul gold seller

    Reply
  93. Theexpert2

    Excellent blog! I found it while surfing around on Google. Content of this page is unique as well as well researched. Appreciate it.,

    russian brides

    Reply
  94. 98Theexpert2

    This post gives the light on a very important topic and provides in-depth knowledge. I want to say thanks for this kind of articles…!

    vittoriafranco

    Reply
  95. 50Theexpert2

    Excellent blog! I found it while surfing around on Google. Content of this page is unique as well as well researched. Appreciate it.,

    Obelisk GRN1 Immersion

    Reply

Leave a Reply

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

*