![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Shutdown and startup Hyper-V Virtual Machine via script Hi, I have tried some scripts for shutting down a virtual machine without success. What I need is a command for shutting down and starting up a named virtual machine in Hyper-V like: Shutdown "SERVERNAME" Startup "SERVERNAME" Can it be that simple? /FC |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Shutdown and startup Hyper-V Virtual Machine via script FC wrote: Quote: > Hi, > > I have tried some scripts for shutting down a virtual machine without success. > > What I need is a command for shutting down and starting up a named virtual > machine in Hyper-V like: > > Shutdown "SERVERNAME" > Startup "SERVERNAME" > > Can it be that simple? > > > /FC starting up is another stoty.. haven't tried WOL on virtual machines yet. Then again, you could simply try using WMI Option Explicit Dim WMIService Dim VMList Dim VMName 'Specify the name of the virtual machine that I want to start VMName = "TestVM" 'Get instance of 'virtualization' WMI service on the local computer Set WMIService = GetObject("winmgmts:\\.\root\virtualization") '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) You can copy, adjust and save all these lines as a VBScript (e.g. StartVM.vbs) by using notepad. And then you can run this VBScript. -- / ) Regards, / /_________ _|__|__) Paul Weterings / (O_) http://www.servercare.nl __/ (O_) ____(O_) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Shutdown and startup Hyper-V Virtual Machine via script There is a powershell library you can use to leverage PS with Hyper-V - that's what I'm doing: http://www.codeplex.com/PSHyperv Then I can issue thusly at the command line: powershell.exe "& {. 'C:\test\hyperv.ps1';Start-VM CALMACIL}" powershell.exe "& {. 'C:\test 1\hyperv.ps1';Suspend-VM CALMACIL}" It currently throws a warning but the script DOES work in regards to starting/stopping/pausing the VM. Blake "Paul Weterings" <Paul-nospam-@xxxxxx-dot-com> wrote in message news:4917670b$0$14837$e4fe514c@xxxxxx Quote: > FC wrote: Quote: >> Hi, >> >> I have tried some scripts for shutting down a virtual machine without >> success. >> >> What I need is a command for shutting down and starting up a named >> virtual machine in Hyper-V like: >> >> Shutdown "SERVERNAME" >> Startup "SERVERNAME" >> >> Can it be that simple? >> >> >> /FC > > starting up is another stoty.. haven't tried WOL on virtual machines yet. > > Then again, you could simply try using WMI > > Option Explicit > > > > Dim WMIService > > Dim VMList > > Dim VMName > > > > 'Specify the name of the virtual machine that I want to start > > VMName = "TestVM" > > > > 'Get instance of 'virtualization' WMI service on the local computer > > Set WMIService = GetObject("winmgmts:\\.\root\virtualization") > > > > '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) > > > > You can copy, adjust and save all these lines as a VBScript (e.g. > StartVM.vbs) by using notepad. And then you can run this VBScript. > > > > -- > > / ) Regards, > / /_________ > _|__|__) Paul Weterings > / (O_) http://www.servercare.nl > __/ (O_) > ____(O_) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| RE: System Center Virtual Machine Manager2007 & HYPER-V in 2008 CORE | Virtual Server | |||
| Microsoft Hyper-V Server 2008 - create virtual machine | Virtual Server | |||
| Moving Virtual Machine from Hyper-v to Virtual Server 2005 | Virtual Server | |||
| Can we run ESX Server on a virtual machine that runs on Hyper V | Virtual Server | |||
| Hyper V: virtual machine will not accept memory more than 4 GB | Virtual Server | |||