Automate Virtual PC 2007 with PowerShell?
Asked Answered
D

3

11

This is basically a duplicate of this question, but the accepted answer was "no" and I would like to keep this question open until getting an actual answer instead of accepting "NO" and giving up.

Stephen Rose told me via Twitter DM to use PowerShell to start and stop Virtual PC VM's and do things like run installations, automatic updates and virus scans, but he hasn't yet responded to my request for any links to resources that describe how to do so.

I've started learning PowerShell, but I can't figure out how to get or work with any information on the list of VM's within Virtual PC.

Edit: Windows Virtual PC (Windows 7 XP Mode) is not the same as Virtual PC 2007. I am running Windows 7 as my host OS, but I'm still using Virtual PC 2007 because I need to maintain the ability to run the guest machines on Vista or XP hosts that won't have the new Windows Virtual PC. I installed Windows Virtual PC briefly to check it out and it had to do a bunch of conversions on my virtual images. The suggestion by @x0n ($vpc = new-object -com virtualpc.application) produces the following error on my system:

New-Object : Cannot load COM type virtualpc.application.
At line:1 char:18
+ $vpc = new-object <<<<  -com virtualpc.application
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand

Edit 2: I used Jeff's code from this answer to list all the COM objects on my system and couldn't find any that looked like they were Virtual PC. So now I'm thinking that the "it's not possible" answer may be correct, but I'm still going to leave this question open in case anyone has any further suggestions for getting PowerShell to work with Virtual PC 2007. In the mean time, I'm strongly considering making the jump to the new Windows Virtual PC in Windows 7 and just not worrying about keeping all my virtual machines compatible with earlier versions of Windows.

Draughtsman answered 9/6, 2009 at 18:0 Comment(0)
M
3

To test some of my own software within a VM I use AutoIt (http://www.autoitscript.com/autoit3/) to start the VM, and within the VM I use it again to start and control my application. Communication is done using a shared folder within the VM (writing the AutoIt script to execute, output of the application like a log).

It's not Powershell, but maybe this helps anyway. :)

Regards,

Sebastiaan

Magocsi answered 9/7, 2009 at 14:38 Comment(2)
Thanks! Looks promising. If it works, I'll accept this answer. Welcome to StackOverflow!Draughtsman
I never got around to testing this out, but this is the best answer and this was my only question without an accepted answer.Draughtsman
R
1

Is this what you're looking for? I'm on Windows 7 that has the "virtual windows xp" feature installed (which is effectively vpc 2007).

[E] PS> $vpc = new-object -com virtualpc.application
[E] PS> $vpc

HostInfo                    : System.__ComObject
VirtualMachines             : System.__ComObject
VirtualNetworks             : System.__ComObject
UnconnectedNetworkAdapters  : System.__ComObject
SupportDrivers              : System.__ComObject
Tasks                       : System.__ComObject
MinimumMemoryPerVM          : 4
MaximumMemoryPerVM          : 3071
SuggestedMaximumMemoryPerVM : 2763
MaximumFloppyDrivesPerVM    : 1
MaximumSerialPortsPerVM     : 2
MaximumParallelPortsPerVM   : 1
MaximumNetworkAdaptersPerVM : 4
MaximumNumberOfIDEBuses     : 2
DefaultVMConfigurationPath  : G:\Users\Oisin\AppData\Local\Microsoft\Windows Virtual PC\Virtual Machines\
SearchPaths                 : {}
USBDeviceCollection         : System.__ComObject
Name                        : Windows Virtual PC
Version                     : 6.1.7084.0
UpTime                      : 2
Rash answered 13/6, 2009 at 0:34 Comment(1)
Windows 7's new Windows Virtual PC is not the same as Virtual PC 2007. This code did not work for me. See my edit in the question.Draughtsman
N
0

It look like it may be possible to automate the creation of virtual images using MS Virtual Server 2005. The following articles detail the use of PowerShell scripts to automate the creation of virtual images:

From part 2, in the section Configuration Tests on a Virtual Machine, it seems possible to transfer files and schedule scripts to run. Using these articles as a basis, it should be possible to automate the building of a MS virtual image in the same way as lordbrain described for a VMware image.

Nur answered 21/7, 2009 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.