Monitor Nutanix tasks w/PowerShell

Recently I started my first meeting with the Nutanix and first of all I downloaded and tested NutanixCmdlets PowerShell Snap-in. It immediately became clear that the set of cmdlets is far from complete. Immediately the decision was made to create an auxiliary Power-NTNX PowerShell module as sometime I made Vi-Module for the VMware.

The module will be updated regularly and an article will be published with each new function. Already today there are plans for three – four functions.

The first function is Wait-NTNXTask.

What is «Task»?

Let’s take for example such cmdlets like Start-NTNXMaintenanceMode or Set-NTNXVMPowerOn. They return not the object on which the action was performed, but a reference to the task created to perform this action.

There remain three big questions – when and how will this task finish and will it finish at all? Once a cmdlet has finished its execution and created its task(s), you lose control of what is happening .

Partially, of course, these questions can be answered by the Get-NTNXTask cmdlet, but the quantity, and especially the quality of useful information less than ideal . What is only the time format in the task properties.

Wait-NTNXTask

The Wait-NTNXTask function allows real-time monitoring of any type of tasks in the Nutanix environment.

It can be tasks that were run earlier, which are returned by the Get-NTNXTask cmdlet, or tasks created by any other cmdlets. Of course, the Wait-NTNXTask supports the pipeline.

Here for interactive host selection we use the Write-Menu function, included in the module. This function will be also useful for us in the future to increase the module functionality.

In addition to visualizing the task progress, the Wait-NTNXTask function returns the object of the task at its completion. Compare with what you get from the Get-NTNXTask cmdlet and, as they say, feel the difference .

As we can see from the function output, entering a host into Maintenance Mode generates a number of subtasks, which can also be visualized by adding the -WaitSubTask parameter.