Scripting, Virtual PC, Virtualization, Windows 7
comments 4

Virtual Windows XP and PowerShell

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..

Filed under: Scripting, Virtual PC, Virtualization, Windows 7


Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.