Script to Start a VM?
- Need a script to start a VM?
Tony Soper
Answers
- John Kelbley has provided one. Leave feedback here or you can e-mail johnkel@microsoft.com/
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
' Obtain an instance of the the class
' using a key property value.
"select * from Msvm_ComputerSystem where elementname =" +"'" + $virtualguest + "'"
Set objShare = objWMIService.Get("Msvm_ComputerSystem.CreationClassName='Msvm_ComputerSystem', ElementName='CCS V1 Head'")
Set objInParam = objShare.Methods_("RequestStateChange").inParameters.SpawnInstance_()
objInParam.Properties_.Item("RequestedState") = 2
Set objOutParams = objWMIService.ExecMethod("Msvm_ComputerSystem.CreationClassName='Msvm_ComputerSystem', ElementName='CCS V1 Head'", "RequestStateChange", objInParam)
tony soper- Proposed As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM
- Marked As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM
- Unproposed As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM
All Replies
- John Kelbley has provided one. Leave feedback here or you can e-mail johnkel@microsoft.com/
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
' Obtain an instance of the the class
' using a key property value.
"select * from Msvm_ComputerSystem where elementname =" +"'" + $virtualguest + "'"
Set objShare = objWMIService.Get("Msvm_ComputerSystem.CreationClassName='Msvm_ComputerSystem', ElementName='CCS V1 Head'")
Set objInParam = objShare.Methods_("RequestStateChange").inParameters.SpawnInstance_()
objInParam.Properties_.Item("RequestedState") = 2
Set objOutParams = objWMIService.ExecMethod("Msvm_ComputerSystem.CreationClassName='Msvm_ComputerSystem', ElementName='CCS V1 Head'", "RequestStateChange", objInParam)
tony soper- Proposed As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM
- Marked As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM
- Unproposed As Answer bytonysoperMSFTThursday, October 30, 2008 7:21 PM

