OBXMAN007
Contributor
Contributor

Automate "I_moved it" When Powering On VMs ?

Jump to solution

Hi!

Below is the simple script I use to power on all vms on a specific host.

I am using this script currently after migrating vms from 3.x to 4.x.

After running script, I am prompted on each vm to verify what happened to vm, etc.(in vcenter) which forces me to have to manually answer the question for each vm.

Is there a way to programmatically answer the prompt by powering on with a certain command line switch or parameter, etc. ?

Specifically, I always want to select the response "I_moved it".

script:

$allvms = Get-VM

$allvms | Start-VM -RunAsync -Confirm:$false | Out-Null

Write-Host "COMPLETE: All Servers Are Powered ON" -ForegroundColor Yellow

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Did you try using the Set-VMQuestion cmdlet ?

Example 3 shows how you could use that cmdlet.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

Did you try using the Set-VMQuestion cmdlet ?

Example 3 shows how you could use that cmdlet.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
OBXMAN007
Contributor
Contributor

Hi Luc,

I will give that a try - haven't used that before - it might work - thanks again.

0 Kudos
OBXMAN007
Contributor
Contributor

Luc,

Once again, you solved it - below is my script - worked like a charm - now I can answer the question en masse:

script:

Get-VM | `

ForEach ( $_ ) {

$vm = $_

Write-Host "Answering Question for VM..." $vm.Name -ForegroundColor Yellow

Get-VMQuestion -QuestionText "you move this" | Set-VMQuestion -Option "moved" -Confirm:$False }

Thanks!!!

0 Kudos
529122530
Enthusiast
Enthusiast

I_moved option will change the vm's uuid

0 Kudos
LucD
Leadership
Leadership

True, but you can select another answer if you don't want to change the UUID.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos