I'm trying to start or save the state of an Hyper V vritual machine. I tried several scripts like:
'Specify the name of the virtual machine that I want to start
VMName = "ITGSRV053"
'Get instance of ‘virtualization' WMI service on the local computer
Set WMIService = GetObject("winmgmts:\\.\ro
'Query for the specific virtual machine that I want to start
Set VMList = WMIService.ExecQuery("SELE
CT * FROM Msvm_ComputerSystem WHERE ElementName='" & VMName & "‘")
' Request a state change on the first VM that is returned
' 2 = start, 3 = stop and 32769 = save state
When i run the pshyper v command sometimes they work but most of the time i get no output and nothing happens. When i run the VBS script above under an elevated cmdline i get the following error:
C:\Scripts\Test.vbs(18, 1) SWbemObjectSet: Invalid query
line 18 is: VMList.ItemIndex(0).Reques
Any advice on this one ?