Using PowerCLI to Answer Virtual Machine Message Questions

September 4, 2013

Table of Contents

Many people, who do not like working hard, but believe in efficiency, automation and working smarter.  Just like scripters. You’ll sometimes hear them say something like “Any process which is repeated once or more should be scripted”.  Thus my personal threshold for committing to a scripted method is higher than one repetition. Mostly, if you are not that good at scripting.

In my environment, I came across a particular process which needed to be repeated 10 or more times – Answering a virtual machine question.  Based on what I’m working on, conceivably I was going to run into this a lot more.  This is what I consider a great candidate for scripting.

The Virtual Machine Message I’m faced with deals with the relocation of the VM.  Via the vSphere Client, my choices were to choose between these three answers: “Cancel”, “I moved it”, or “I copied it”.  I don’t have the patience or desire to mouse through this hundreds of times.

If you want to provide the same answer like, “I moved it”, for every VM in inventory which has this question.  The script to accomplish this is not that complicated, even to those who are not that good.  Once the PowerCLI connection is established to the vCenter Server or ESX(i) host, it’s a one-liner.  Following is the PowerShell script which gets the job done for the above situation:

Connect-VIServer vc501.boche.lab

Get-VM | Get-VMQuestion | Set-VMQuestion -Option “I moved it” -Confirm:$false

Note that there are different types of Virtual Machine Message questions which will yield a different set of possible answers.  Be sure to query a VM having a question via PowerCLI for the possible answers to that question.  Get-VM | Get-VMQuestion -full should do it.  Once the possible answers are revealed, use Set-VMQuestion -Option to provide an answer.

Another point to note is that the script above will cycle through all VMs in inventory, and for those having a question, it will provide the same response for each VM.  Thus the assumption is made that all VMs with pending questions have the same question being asked.  To respond to explicit question types or to filter the VMs being looped through, the script would need to be refined.

For more information on the Get-VMQuestion or Set-VMQuestion PowerCLI cmdlets, use Get-Help Get-VMQuestion -full or Set-Help Get-VMQuestion -full respectively.

 

 

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

A Look at vCenter 5.5 SSO RC Installation

vCenter single sign on (SSO)  vsphere 5.5  release has several improvements, like the following: Completely re-written from the ground Multi-master architecture Native replication mechanism SSO now has site awareness (think

vSphere 5.1 New Storage Features

VMFS File Sharing Limits In previous versions of vSphere, the maximum number of hosts which could share a read-only file on a VMFS volume was 8. The primary use case

Easy File & Code Manager

Easy File Manager FileZilla Best Server Manager Tools Download FileZilla Client You can use FileZilla to manage websites and servers and edit code in real-time or for simple backup methods

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March