VMware Cloud Community
Engelsman
Enthusiast
Enthusiast

get-vm set-vmquestion works, but very slow

Hello all,

I'm using this oneliner to answer vm questions:

get-vm | where {$_.powerstate -eq "PoweredOn"}| get-vmquestion | Set-VMQuestion -Option "Abort" -Confirm:$false

It works, but it is awfully slow; about 2 VM's / minute. Is there a better/faster way to do this? Since I'll have to answer 100+ questions like this.

Reply
0 Kudos
2 Replies
aevrov
VMware Employee
VMware Employee

Hi Engelsman,

Set-VMQuestion really has some poor performance. We'll fix that in the next release. Meanwhile, check if this script works faster for you:

Connect-VIServer ####


$filter = @{"runtime.powerState"="poweredOn"}

Get-View -ViewType "VirtualMachine" -Filter $filter -Property "runtime.question" | % {
    if( $_.Runtime -and $_.Runtime.Question){
        $answer = $_.Runtime.Question.Choice.ChoiceInfo | where { $_.Label -ieq "Abort" }

        $_.AnswerVM( $_.Runtime.Question.Id, $answer.Key )

    }
} 

Regards,

-Angel

Engelsman
Enthusiast
Enthusiast

Hi Angel,

Thanks for the feedback. I'll give your script a try, to see how fast it goes!

Henk

Reply
0 Kudos