Monitor Nutanix tasks w/PowerShell

Cover

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.
Get-NTNXVM -SearchString vm1 | Set-NTNXVMPowerOn
Get-NTNXVM -SearchString vm1 | Set-NTNXVMPowerOff

01.Wait-NTNXTask_Set-NTNXPowerOff

  • 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 Emoj.

  • 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 Emoj. What is only the time format in the task properties.

02.Wait-NTNXTask_Get-NTNXTask

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.

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.

03.Wait-NTNXTask_Write-Menu

04.Wait-NTNXTask_Start-NTNXMaintenanceMode

  • 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 Emoj.

05.Wait-NTNXTask_Output

  • 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.
Start-NTNXMaintenanceMode -Hostid (Write-Menu -Menu (Get-NTNXHost | sort name)).uuid -EvacuationOption LIVE_MIGRATE -NonMigratableVmOption ACPI_SHUTDOWN_AND_POWER_OFF | Wait-NTNXTask -WaitSubTask

06.Wait-NTNXTask_Subtasks

  • Regardless of whether you visualize subtasks or not, they are in any case present in the function output with SubTask prefix and the type of their parent task in the Type property.

Summary

  • The Wait-NTNXTask is advanced function and supports full set of standard advanced parameters like -ErrorAction or -Verbose.

07.Wait-NTNXTask_Get-Help

  • 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

You might also like

NUTANIX Power-NTNX Home
VMware Vi-Module Home
Write-Menu – Create interactive dynamic Menu in PowerShell
New-PercentageBar – Create colored and adjustable Percentage Bar in the PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s