Quite frequently there are questions in the VMTN PowerCLI Community for scripts that report on the tasks that ran in a vSphere environment.
The PowerCLI pssnapin provides a Get-Task cmdlet, but that only provides information about the recent tasks. An alternative is to use the Get-VIEvent cmdlet and extract all the TaskEvent entries.
But why not use the TaskHistoryCollector and it’s methods ? It provides many filtering options, and since this filtering is done in vSphere itself, this way of working is inherently much faster than using a filter in your script.
In analogy with the Get-VIEventPlus function, I published in my Get the vMotion/svMotion history post, here is the Get-TaskPlus function !
Update February 13th 2020
- Added logic to break out of do-while loop and destroy the TaskCollector to avoid issues with max 32 collectors
Continue reading Task Data Mining – An improved Get-Task
In a previous post, called Events, Dear Boy, Events – Part 2, I mentioned that some tools/add-ons use a special event type called ExtendedEvent. Two classic examples are the Converter and the Update Manager. If you want to compile a report for any these tools it’s important to understand what is available in the extended events they produce.
If you want to know if there are any other tools/add-ons in your vSphere environment that produce extended events, then you can use the first script from the Events, Dear Boy, Events – Part 2 post to get a complete list of all available extended events.
In this post I’ll show how to use the Converter extended events.
Continue reading Events – Part 6 : Working with extended events – Converter
There was an interesting question in the PowerCLI Community on how to use the -RunAsync parameter. The user wanted to create a number of new guests and start each guest once the creation was complete. This can be done rather easily by using a New-VM cmdlet and piping the result to the Start-VM cmdlet.
Only problem was, the creation of the new guests was done in Async mode.
That’s where the Get-Task cmdlet and the use of a hash table come in handy.
Continue reading About Async tasks, the Get-Task cmdlet and a hash table