Does Virtual Server 2005 R2 have a command line interface, that's versatile enough?
Here is a situation. I run a Win2k VM on an old memory constrained machine. I allocate it 378MB of RAM and the VM runs just fine. Once a month, inside the VM, I backup the (a very large) database, compress it using 7Zip and ftp it to the backup site (all in a script).
Unfortunately the compression part takes a massive amount of RAM (far exceeding the 378MB), it goes for the paging file and brings absolutely everything to a crawl and literally takes 2-3 days, if left unattended. So to fix this, I have to shutdown the VM, give it temporarily 768MB of RAM and then the whole thing finishes in 20 minutes.
So, is there a way do the following automatically from the host machine in a script?
- Shutdown the guest OS (I think, I got this part)
- Change the RAM allocation from 378 to 768
- Start the guest OS again
then, 1 hour later, do everything in reverse.
Edit: thx to Wesley 'Nonapeptide' for the links. I cobbled up a script and it works like butter. It takes the memory amount as a parameter. Here it is for any folks who might want to do this:
if Wscript.Arguments.Count = 0 then
Wscript.Quit
end if
memory = Wscript.Arguments(0)
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("vbRad.com")
Set objGuestOS = objVM.GuestOS
Set objTask = objGuestOS.Shutdown()
objTask.WaitForCompletion(600000)
objVM.Memory = memory
Set objTask = objVM.Startup()
objTask.WaitForCompletion(600000)
The .memory attribute for a VM object is what you would be looking for. Check out this list of methods and properties on a VM object.
The .startup method is what you're looking for to start it back up.
You might also like this second part of a tutorial that shows how to manage virtual machines with PowerShell. That shows a few examples of how VM configurations are twiddled with.
Finally, bookmark the MSDN Microsoft Virtual Server Reference. It rocks.