How to know the state of virtual machine on Hyper-V
is there script find out state of virtual machine running on hyper-v server (2008, r2)? wanted know if vm "running" or "saved"? script work guest os without integartion services, linux, xp sp1.
thanks.
hi,
the code should following, “$vms = gwmi -class "msvm_computersystem"-namespace” , "root\virtualization"-computername "." on same line.
--------------------------------------
$vms = gwmi -class "msvm_computersystem"-namespace "root\virtualization"-computername "."
foreach ($vm in $vms)
{
switch ($vm.enabledstate)
{
2{$state="running" }
3{$state="stopped" }
32768{$state="paused" }
32769{$state="suspended" }
32770 {$state="starting" }
32771{$state="taking snapshot" }
32773{$state="saving" }
32774{$state="stopping" }
}
write-host $vm.elementname `,` $state
}
-------------------------------------
vincent hu
Windows Server > Hyper-V
Comments
Post a Comment