http://www.ravichaganti.com/blog/?p=447

Virtual Windows XP and PowerShell

Written on May 23, 2009 – 8:47 pm | by ravikanthchaganti | 382 views

There is nothing really special you need to do know about PowerShell support for the Virtual Windows XP or Windows XP mode in Windows 7. This is because WinXP mode uses Virtual PC as the base platform. Hence, you could just use the COM objects provided by Virtual PC application and get the information you need. For example, to get COM object instance in to a variable, all you need to do is

PS1> $vpc = New-Object -COM VirtualPC.Application -strict

 Once you have the instance, try

PS1> $vpc.VirtualMachines

This will display all the virtual machines running on your Windows 7 system. By default, if you don’t have any custom VMs, this will display the Virtual Windows XP instance. On my system, it looks something like this

Virtual Windows XP

Virtual Windows XP

Now, these properties could be modified using PowerShell. For example, if you want to modify the “ShutdownActionOnQuit”, you need to do the following

PS1> $vms = $vpc.VirtualMachines

PS1> $vm = $vms.Item(1)

PS1> $vm.ShutdownActionOnQuit = 0

$vms.Item(1) will get the Virtual Windows XP instance in to $vm variable and $vm.ShutdownActionOnQuit = 0 will modify the property value.

If you want to see a list of all properties and methods support under PowerShell for a Virtual Machine instance,

PS1> $vm | Get-Member -MemberType Property

PS1> $vm | Get-Member -MemberType Method

Simple, isn’t it. Explore more of those properties and methods yourself. Enjoy..