Warning: Declaration of c2c_ConfigureSMTP::options_page_description() should be compatible with C2C_Plugin_023::options_page_description($localized_heading_text = '') in /home/harold13/public_html/wp-content/plugins/configure-smtp/configure-smtp.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at /home/harold13/public_html/wp-content/plugins/configure-smtp/configure-smtp.php:47) in /home/harold13/public_html/wp-content/plugins/sg-cachepress/core/Supercacher/Supercacher_Helper.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at /home/harold13/public_html/wp-content/plugins/configure-smtp/configure-smtp.php:47) in /home/harold13/public_html/wp-content/plugins/sg-cachepress/core/Supercacher/Supercacher_Helper.php on line 70
VBScript for Start/Stop/Save Hyper-V VMs… | HaroldLiles.com
Select Page

I found this useful bit of VBScript code from Ben Armstrong:
http://blogs.msdn.com/virtual_pc_guy/archive/2008/01/29/starting-a-hyper-v-virtual-machine.aspx

Here it is basically:
Option Explicit

Dim
WMIService
Dim VMList
Dim VMName

‘Specify the name of the virtual machine that I want to start
VMName = “Windows Server 2003”

‘Get instance of ‘virtualization’ WMI service on the local computer
Set WMIService = GetObject(“winmgmts:\.rootvirtualization”)

‘Query for the specific virtual machine that I want to start
Set VMList = WMIService.ExecQuery(“SELECT * 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
VMList.ItemIndex(0).RequestStateChange(2)

Pin It on Pinterest

Share This