發問發問
 

已答覆Script to Turn Off all Hyper-V VMs?

  • Thursday, 30 October, 2008 19:02tonyso 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
    Need a script to Turn Off all the VMs running on a server with the Hyper-V role enabled?
    Tony Soper

解答

  • Thursday, 30 October, 2008 19:04tonyso 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆包含代碼
    John Kelbley provides one, you can leave feedback here or contact johnkel@microsoft.com:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
    Set vmcollecion = objWMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem",,48)

    ' loop through all instances in collection
    For each vm in vmcollecion
     RequestReturn = vm.RequestStateChange(3)
    Next



    Tony Soper
    • 已編輯tonyso Thursday, 30 October, 2008 19:04has code
    • 已標示為解答tonyso Thursday, 30 October, 2008 19:04
    •  

所有回覆

  • Thursday, 30 October, 2008 19:04tonyso 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     已答覆包含代碼
    John Kelbley provides one, you can leave feedback here or contact johnkel@microsoft.com:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
    Set vmcollecion = objWMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem",,48)

    ' loop through all instances in collection
    For each vm in vmcollecion
     RequestReturn = vm.RequestStateChange(3)
    Next



    Tony Soper
    • 已編輯tonyso Thursday, 30 October, 2008 19:04has code
    • 已標示為解答tonyso Thursday, 30 October, 2008 19:04
    •  
  • Monday, 24 November, 2008 13:26DungKHoang 使用者勳章使用者勳章使用者勳章使用者勳章使用者勳章
     
     You can also check my blog on Hyper-V  and PowerShell.
    I have some examples using PowerShell coding against WMI

    EnjoY!
    /Dung

    http://dungkhoang.spaces.live.com