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

}

-------------------------------------

 

best regards,

vincent hu

 

 



Windows Server  >  Hyper-V



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file