[Script] Listing Virtual Machines with Windows Virtual PC
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
Cheers,
Ben