-- Ben Armstrong, Virtualization Program Manager
Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).
To get things started here, I thought I would put up some samples for the most basic scripts I could think of for interacting with Windows Virtual PC. So here is a sample script that just lists the virtual machines that are currently registered on the local system:
PowerShell:
# Connect to Virtual PC
$vpc=new-object –com VirtualPC.Application –Strict
write-host "Virtual Machines:"
write-host "================="
# Iterate over the virtual machines and display their names
foreach ($vm in $vpc.VirtualMachines)
{
write-host $vm.name
}
VBScript:
option explicit
Dim vpc
Dim vms
Dim vm
'Connect to Virtual PC
Set vpc = CreateObject("VirtualPC.Application")
'Get collection of virtual machines
set vms = vpc.VirtualMachines
Wscript.Echo "Virtual Machines:"
Wscript.Echo "================="
'Iterate over the virtual machines and display their names
For Each vm in vms
Wscript.Echo vm.Name
Next
I am running Win7 RC. I have VPC 6.0 installed. I get an error doing the New-Object
PS C:\> $vpc=new-object -com VirtualPC.Application -Strict
New-Object : Cannot load COM type VirtualPC.Application.
At line:1 char:16
+ $vpc=new-object <<<< -com VirtualPC.Application -Strict
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand
Doug -
Are you using Virtual PC 2007, or Windows Virtual PC?
Cheers,
Ben
Is there something similar to enumerate the machines for VirtualPC 2007?
Nikhil -
No, Virtual PC 2007 has no scriptable interface.