PropertyCollector.RetrievePropertiesEx instead of VcVirtualMachine.recentTask

I'd like to get the results of VcVirtualMachine.recentTask, but according to documentation it no longer works:

In releases after 5.0 API vSphere, vSphere servers cannot generate notifications of updated collector of property to this property. To get the last value of the property, you can use the PropertyCollector RetrievePropertiesEx or WaitForUpdatesEx methods.


I have not found any example of using it and the documentation really helped me to understand how to use it.

Could someone point me to the right direction?

Maachah

This should work for you - using a TaskHistoryCollector

Tags: VMware

Similar Questions

  • getAllVMsOfCluster slow vs Get - VM

    Hi all

    I'm trying to convert a simple script PowerCLI broadband vCO (or shares in the future, when debugging is available for them...)

    The PowerCLI script is very simple, it loops through all the virtual machines in a cluster and the vRAM output average / vCPU per VM.

    The problem is that the action getAllVMsOfCluster take a lot of ugly of time (more than 3 minutes!) to return on a cluster with VM ~ 200, while the Get - VM cmdlet on the same cluster take 10-20 sec.

    I think the Get - VM cmdlet uses a view and the getAllVMsOfCluster Action simply traverses the objects returned by the sdk/mob...

    Is there a way to speed up the process (except using the plug-in, PowerShell, which I try to avoid as much as possible).

    Here is the PowerShell and vCO of this simple script version:

    Here's the script PowerCLI:

    $clusterName = "mycluster.

    $cluster = get-Cluster-name $clusterName

    $vms = $cluster | Get - VM

    $nbVMs = $vms.length

    $nbvCPUs = 0

    $nbvRAM = 0

    foreach ($vm to $vms)

    {

    $nbvCPUs += $vm. NumCpu

    $nbvRAM += $vm. MemoryMB

    }

    $nbvRAM = $nbvRAM / 1024

    $nbvRAM = $nbvRAM / 1024

    $avgvRAMPerVM = $nbvRAM / $nbVMs

    $avgvCPUPerVM = $nbvCPUs / $nbVMs

    Write-Host "nbVMs: $nbVMs".

    Write-Host "nbvCPUs: $nbvCPUs".

    Write-Host "nbvRAM: $nbvRAM".

    Write-Host "avgvRAMPerVM: $avgvRAMPerVM".

    Write-Host "avgvCPUPerVM: $avgvCPUPerVM".

    I converted this to a vCO feed that looks like this:

    Entry:

    cluster as VC:ClusterComputeResource

    Output:

    avgvRAMPerVM under the number

    avgvCPUPerVM under the number

    Flow:

    Action: getAllVMsOfCluster

    Entry: Entry flow "cluster."

    Output stream: attribute "vms" in the table of VC:VirtualMachine

    Scriptable task: "do the math".

    Entry: Flow attribute "vms" in the table of VC:VirtualMachine

    Output:

    AvgvRAMPerVM output stream

    AvgvCPUPerVM output stream

    Script:

    var nbVMs = vms.length;

    var nbvCPUs = 0;

    var nbvRAM = 0;

    for (var i in SMV)

    {

    nbvCPUs += vms [i].config.hardware.numCPU;

    nbvRAM += vms [i].config.hardware.memoryMB;

    }

    nbvRAM = nbvRAM / 1024;

    avgvRAMPerVM = nbvRAM / nbVMs;

    avgvCPUPerVM = nbvCPUs / nbVMs;

    System.log ("nbVMs:" + nbVMs);

    System.log ("nbvCPUs:" + nbvCPUs);

    System.log ("nbvRAM:" + nbvRAM);

    System.log ("avgvRAMPerVM:" + avgvRAMPerVM);

    System.log ("avgvCPUPerVM:" + avgvCPUPerVM);

    I thought about it...

    Although it is not a lot of documentation for it to the vCO, by using a view I could speed things up.

    Below, the variable 'cluster' is a VC:ClusterComputeResource taken as Input of the workflow element.

    The final code looks like this:

    Set a bunch of var to store the results:

    var nbVMs = 0;

    var nbvCPUs = 0;

    var nbvRAM = 0;

    Get ViewManager & PropertyCollector singleton

    var viewManager = cluster.sdkConnection.viewManager;

    var propertyCollector = cluster.sdkConnection.propertyCollector;

    Create a ContainerView for virtual machines from this group

    var vmList = new Array();

    vmList.push ('VirtualMachine');

    Bird = viewManager.createContainerView (cluster, vmList, true);

    Create an ObjectSpec to define the origin point of the search and ignore the element root (cluster) of the research

    var objSpec = new VcObjectSpec();

    objSpec.obj = myView.reference;

    objSpec.skip = true;

    Create a TraversalSpec to identify the type of object that we are interested in.

    var traversalSpec = new VcTraversalSpec();

    traversalSpec.name = "traverseEntities";

    traversalSpec.path = "display";

    traversalSpec.skip = false;

    traversalSpec.type = "ContainerView;

    Attach the TransversalSpec to our ObjectSpec search root.

    objSpec.selectSet = new Array (traversalSpec);

    Create a PropertySpec to identify the properties that we are looking for in the selected object

    propertySpec var = new VcPropertySpec();

    propertySpec.type = 'VirtualMachine ';

    propertySpec.pathSet = new Array ('config.hardware.memoryMB', 'config.hardware.numCPU');

    Create a PropertyFilterSpec to connect the object search & property search spec

    var propertyFilterSpec = new VcPropertyFilterSpec();

    propertyFilterSpec.objectSet = new Array (objSpec);

    propertyFilterSpec.propSet = new Array (propertySpec);

    Create an object of RetrieveOptions by default (the default values are fine)

    var retrieveOptions = new VcRetrieveOptions();

    var result = null;

    to loop through the results:

    do

    {

    If (result is nothing)

    {

    Get the first batch of results (first 100 results by default?)

    result = propertyCollector.retrievePropertiesEx ([propertyFilterSpec], retrieveOptions);

    }

    on the other

    {

    During subsequent calls, get the next batch of 100 results

    result = propertyCollector.continueRetrievePropertiesEx (result.token);

    }

    If (result! = null)

    {

    for (var i in result.objects)

    {

    (var j in result.objects [i] .propSet)

    {

    var name = result.objects [i] .propSet [j] .name;

    var val = result.objects [i] .propSet [j] .val;

    If (name is 'config')

    {

    nbvCPUs += result.objects [i] [j] .propSet.val.hardware.numCPU;

    nbvRAM += result.objects [i] [j] .propSet.val.hardware.memoryMB;

    }

    }

    nbVMs ++;

    }

    }

    }

    While (result.token! = null); the "token" property to determine whether or not there are more results to recover beyond the current batch.

    I want the vRAM GB not MB.

    nbvRAM = nbvRAM / 1024;

    Average vRAM & vCPU per VM in this cluster

    var avgvRAMPerVM = nbvRAM / nbVMs;

    var avgvCPUPerVM = nbvCPUs / nbVMs;

    Save all the outputs to verify that everything works:

    System.log ("nbVMs:" + nbVMs);

    System.log ("nbvCPUs:" + nbvCPUs);

    System.log ("nbvRAM:" + nbvRAM);

    System.log ("avgvRAMPerVM:" + avgvRAMPerVM);

    System.log ("avgvCPUPerVM:" + avgvCPUPerVM);

  • I tried to download macOS Sierra for the last hours on my Mac, but it is still holding still to download. Should I download the El Capitan instead? All sites tell me that I should update my Safari.

    I tried to download macOS Sierra on my macbook pro iOS 10 for a few hours and it still has several hours to go. Should I just download the Capitan instead? All sites tell me that I should update my Safari or I wouldn't even through this disorder.

    You must complete the download of Sierra. It is a very large file and will take some time, especially on a slow Internet connection.

    (145165)

  • Update IOS Sierra shows only 8 GB instead of 16 GB

    After the upgrade to my system Sierra shows that 8GB instead of 16 GB in which I have two installed RAM 8 GB cards.

    Ive done a reset of the NVRAM/PRAM memory and no help.

    Does anyone else have this problem?

    I would try reinstalling the memory in Bank 1. I doubt that Sierra has nothing to do with it, just a coincidence I guess. I've not seen anyone else with this issue since Sierra was released.

  • Why iTunes 12.5 play my library of songs together, instead of playing the album from the chosen song

    When I get to the album, and and select a song in an album, itunes plays all songs in the library, instead of just playing this specific album, beginning of the song I've selected.

    Double-click the first track you want to play instead of use the blue play button.

    TT2

  • How do you default Center widgits instead of alerts notification

    With the new update iOs 10 on my iPhone 6 s, the (ample down from the top) notification defaults to the display screen alerts.  Is it possible to have by default the widget screen instead?

    Sorry, but this isn't an option in the iOS. You can get on-screen widget directly from the home screen by sliding from left to right, all by dragging up and down poster notifications screen.  No gesture is editable.

    Or you can submit your ideas to Apple at http://www.apple.com/feedback/

  • Messages displays instead of contacts phone numbers

    Messages on my iPad displays almost every conversation by phone instead of by contact number. If I type the number at the top of a conversation I gives me the opportunity to add it to an existing contact, and I can navigate to the appropriate contact and see that the phone number is already there. Oddly enough, I have a contact which conversation shows by contact with the photo and all.

    All messages are correctly displayed by contact on my iPhone or Messages on my iMac.

    On the iPad, I went iCloud preferences and deselected 'Contacts' choose to have to remove them from the iPad and then their synchronized again. I also reset the iPad (i.e. held the Home and Power buttons until stop you it and then the Apple screen reappeared before releasing the buttons). The problem persists: Messages does not (mostly) my Contacts.

    What else can I try?

    Thanks in advance,

    Steve =: ^)

    You might be looking at threads of message that began with this phone number for so long, or were part of a group message?

    What happens if you try to messages with a clean slate is by sending a message to a new person marks (starting a new message thread) or by removing all your message the previous discussions (including group messages) involving a person who currently stands as a phone number?

  • Blue square with a question mark instead of a picture

    I'm on Messages to use with your Mac - Apple Support.

    Instead of pictures (or), I get a blue square with a question mark in it.

    This does not happen with all Web sites, but I wonder why it's happening with an Apple site, and how I can see the photos.

    It sounds like a broken image link.

    Post a screenshot if you can, so that we can confirm. The page seems OK after a glance. Command + shift + 4 then do slide on the affected area, add the image to the desktop to this site via the camera icon.

    If you have browser extensions, disable them and repeat the test. Also try a different web browser if possible to see if it is the scale of the system or only Safari. Is - this Safari you use?

  • ITunes is of note to the whole Albums instead of individual songs

    When I evaluate an individual song album is classified.

    This issue seems to occur only when evaluating a song from a playlist.

    I can't repeat this behavior.  It seems to happen randomly.  I can do the same procedure 10 times, and it can occur only 1/10.

    This is not a recent problem.  I was aware for well over a year.  At no time I never rated an album, however I regularly have to wade through my appreciation according to playlists smart weeding nominal albums.

    Black Blue stars are manual sides. You can edit the ratings in most views where they can be seen, with the exception of the column Album of note in the view of songs where they are not active. Activate and expand the column work instead, when it is quite wide there is an active side that you can modify.

    Dark Gray stars are ratings auto generated in response to manual ratings. Manually securities on the side of an album will be automatically rate the album if it is not already evaluated. Notation manually an album will self evaluate any track not classified.

    You can remove the automatic ranking with my scripts ClearAlbumAutoRating or ClearTrackAutoRating , which sets the manual values of 1%. A score of zero allows the behavior of auto side where not classified titles are given a side-car, which corresponds to the side of the album, and an album not class boasts a rating that reflects the rounded average of no assigned manually track. Match scripts to make things if you want to restore the automatic categorization later.

    In recent months, it seems to be another issue where after titles were noted on a device synchronization can result in an album to get a full capacity in iTunes. I hope that Apple are aware of this problem and can be solved in a generation later... maybe.

    Use iTunes your comments if you want to make suggestions to Apple.

    TT2

  • Why 10.01 are my alpha songs sorted by the artist instead of alpha by song title?

    How can I get my alpha songs sorted by title instead of alpha by artist 10.01

    Thank you to have communities of Apple support, palowootten.

    If I understand correctly, your music on your iPhone is only sort by artist, but you want to have your music sorted by title. I like such as well since it mixes things up a little bit for me, and I'll be happy to show you where this setting is.

    On your phone, tap Settings > music > songs of sorting & Albums > and type 'by title '.

    Have a great day!

  • Shows incoming calls to the United States instead of the city and the State

    IiPhone 6plus, IOS 10.  Incoming calls from unknown number of shows in the United States instead of / the State of the city. How can I fix this. Thank you

    Settings > general > language and region > region = 'United States'... assuming that is where you are.

  • where to download photos for Mac (instead of iPhoto)

    I guess I'll have to go to El Capitan, so I can use photos for Mac instead of iPhoto I crashes.

    Are the Photos of Max, a free program, and where I can get it? I'm looking on the Apple site and find information on how it is good, but no place to download. Thank you.

    Update OSX to El Capitan, Photos is included

  • whenever I have an ical event he opens Outlook instead of calendar on my mac

    Whenever I receive an ical event and open it, it opens Outlook (which I never use) instead of the calendar on my mac, why?

    Calendar/preferences/general - what is set as default calendar?

  • My iPhone can connect to the computer via Wifi instead of cable? Because I figured that my head of the telephone cable i have problem if the computer cannot detect my folder after plugging in the cable.

    My iPhone can connect to the computer via Wifi instead of cable? Because I figured that my head of the telephone cable i have problem if the computer cannot detect my folder after plugging in the cable.

    Sync your iPhone, iPad or iPod touch with iTunes using a WiFi - Apple...

  • Firefox Web sites don't display properly or to connect with websites and instead shows an error on the certificates.

    due to the fact that download a picture takes forever and I don't have time so that it ends before that my beard gray, I have provided links to the screenshots instead.

    https://gyazo.com/239be705c99a4aa7febcce6932c9e7f0

    https://gyazo.com/6a8d36aaae1da4b56a193b0940b2fc8c

    I tried all the stuff in your store and none of them worked, relocation/delete/reset etc nothing works at all the. It's still messed up.

    Thanks for the follow-up - help the steps in http://support.eset.com/kb3126/ ?

Maybe you are looking for

  • File now send later

    I'm curious to know is anyway to record a video message, save and send later? I have Skype 7.22 Windows 7

  • move data from mid 2007 iMac for iMac 27 5 k

    I would like to move some of the software and data from my current iMac 24 "mid-2007 for my new iMac 27' 5 k. Someone at - it instructions on how to do it?  I found the instructions for ALL my software and data, but I want to only some of them. Thank

  • Sanitizer spilled in my iPod and now it will not load. What is the problem with i?

    Disinfectant for spilled in my iPod (5th generation), and now it will not load. What is wrong with him? I could clearly see inside the screen before he died. I have biught a new charger thinking mines was just broke, but he does not always load.

  • Need driver for Satellite A210 - 12Z PSAEGE

    Hi people, I need your help. I'm looking to WinXP Driver for this laptop but found nothing of Toshiba. I tried to install the Omegadrivers for display and the VIA Allinone Driver package for the chipset, but it does not work. Can anyone tell chipset

  • Windows imaging component for 64 bit XP - but mine is 32?

    I'm loading quickbooks 2013 - it will not install without a windows imaging Component file - find receive Microfiber downloads it says it requires a 64 bit XP - then it will download... says it is not a file win32dll... What is the fix?