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
What is «Task»?
- Let’s take for example such cmdlets like
Set-NTNXVMPowerOn. They return not the object on which the action was performed, but a reference to the task created to perform this action.
Get-NTNXVM -SearchString vm1 | Set-NTNXVMPowerOn Get-NTNXVM -SearchString vm1 | Set-NTNXVMPowerOff
- 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-NTNXTaskcmdlet, but the quantity, and especially the quality of useful information less than ideal . What is only the time format in the task properties.
Wait-NTNXTaskfunction 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-NTNXTaskcmdlet, or tasks created by any other cmdlets. Of course, the
Wait-NTNXTasksupports the pipeline.
Get-NTNXTask –Taskid $id | Wait-NTNXTask Get-NTNXVM -SearchString vm1 | Set-NTNXVMPowerOn | Wait-NTNXTask
- Let’s look at a more interesting and practical example – entering an AHV host into Maintenance Mode.
Start-NTNXMaintenanceMode -Hostid (Write-Menu -Menu (Get-NTNXHost | sort name)).uuid -EvacuationOption LIVE_MIGRATE -NonMigratableVmOption ACPI_SHUTDOWN_AND_POWER_OFF | Wait-NTNXTask
- 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-NTNXTaskfunction returns the object of the task at its completion. Compare with what you get from the
Get-NTNXTaskcmdlet 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
Start-NTNXMaintenanceMode -Hostid (Write-Menu -Menu (Get-NTNXHost | sort name)).uuid -EvacuationOption LIVE_MIGRATE -NonMigratableVmOption ACPI_SHUTDOWN_AND_POWER_OFF | Wait-NTNXTask -WaitSubTask
- Regardless of whether you visualize subtasks or not, they are in any case present in the function output with
SubTaskprefix and the type of their parent task in the
Wait-NTNXTaskis advanced function and supports full set of standard advanced parameters like
- For more details about the function, please take a look at the content based help and examples.
Get-Help Wait-NTNXTask -Full Get-Help Wait-NTNXTask –Examples Get-Alias –Def Wait-NTNXTask Get-Help Wait-NTNXTask –Parameter Task