Virtual Windows XP and PowerShell

by ravikanthchaganti on May 23, 2009
1,205 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..

Related Posts

{ 2 trackbacks }

Site d'information sur Windows Server 2008 R2 et Windows 7 : Virtual Windows XP and PowerShell
June 1, 2009 at 8:38 pm
PowerShell sur Technet et en français : Virtual Windows XP and PowerShell
June 1, 2009 at 8:39 pm

{ 2 comments… read them below or add one }

Vijay May 23, 2009 at 10:14 pm

Nice post Buddy..!!! Really informative..!!

ravikanthchaganti May 24, 2009 at 9:42 am

Thanks Vijay

Leave a Comment

Previous post:

Next post: