Uncategorized

Managing Virtual Machine questions with PowerCLI

Greetings to all vSphere administrators out there! This post will illustrate another vSphere feature that is interesting from an automation perspective, namely – virtual machine questions.

Virtual Machine questions are questions that must be answered before the operation of a given virtual machine can continue. These questions can arise in different situations. These situations are usually rare but when they occur they block the virtual machine and require attention before the VM can be started again. Let’s see how we can elegantly handle those VM questions with PowerCLI.

One case where a VM question can arise is when you physically copy a VM form one Datastore location to another and then add the newly copied VM to the inventory. In this case the ESX server wants to know if you have moved the VM or copied it. In the first case the UUID of the VM is preserved whereas in the second case a mew UUID is generated. The specifics of this scenario are described in this KB. The important thing here is that when you try to start the VM with PowerCLI you will get an error stating that a VM question must be answered before the VM can start.

PS D:\ > Get-VM QuestionVM | Start-VM

Start-VM : 6/27/2011 1:11:55 PM    Start-VM        This VM has questions that must be answered before the operation can continue.

At line:1 char:29

+ Get-VM *question* | Start-VM <<<<

    + CategoryInfo          : InvalidOperation: (:) [Start-VM], VmBlockedByQuestionException

    + FullyQualifiedErrorId : Client20_VmServiceImpl_WrapInVMQuestionWatchingTask_HasQuestions,VMware.VimAutomation.ViCore.Cmdlets.Commands.StartVM

PS D:\ >

 Now you know a question is preventing this VM from starting. What you want to do is get the question and answer it. This is done with the Get-VMQuestion and Set-VMQuestion cmdlets.

PS D:\ > Get-VMQuestion

 

Text                                               Options              Default

—-                                               ——-              ——-

msg.uuid.altered:This virtual machine might have b {Cancel, I moved it, I copied i

een moved or copied.                                I copied it}        t

In order to configure certain management and networking features, VMware ESX needs to know if this virtual machine was moved or copied.

If you don't know, answer "I copied it".

PS D:\ >

You can answer the question this way:

PS D:\ > Get-VMQuestion | Set-VMQuestion –Option "I copied it"

Confirmation

Answer 'I copied it' to VM question 'msg.uuid.altered:This virtual machine might have been moved or copied.

In order to configure certain management and networking features, VMware ESX needs to know if this virtual machine was moved or copied.

If you don't know, answer "I copied it".

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): Y

PS D:\ >

 Alternatively, you can specify that you want to give the default answer of the question (every VMQuestion has a default answer):

PS D:\ > Get-VMQuestion | Set-VMQuestion –DefaultOption

You can also cancel the Power-On operation by answering “cancel” to the question:

 PS D:\ > Get-VMQuestion | Set-VMQuestion –Option cancel

 

I hope this will be useful.

Regards,

-Angel Evrov, MTS at VMware