Running PowerShell 1.0 and 2.0 on the same machine

May 12, 2009

6 comments

Windows XP Mode (XPM) for Windows 7 makes it easy to install and run many of your Windows XP productivity applications directly from a Windows 7 based PC. It utilizes virtualization technology such as Windows Virtual PC to provide a Virtual Windows XP environment for Windows 7. Windows XP Mode provides a 32-bit Windows XP Professional Service Pack 3 (SP3) environment pre-loaded on a virtual hard disk.

In this post I’ll demonstrate how to install, publish and launch PowerShell 1.0 side by side with PowerShell 2.0 which is already a part of Windows 7. First, you need to download Windows Virtual PC Beta and Windows XP Mode. Lets’ start.

Install Windows6.1-KB958559-x64.msu and reboot if asked to. Next run VirtualWindowsXP.msi

 

It is recommended to save the password you choose. That way you won’t have to enter the user credentials each time you launch XPM.

At this point XPM is loading and initializing its components

 

XPM performs auto logon (if you choose to save the user credentials). When you open My Computer you’ll see your Windows 7 local drives as mapped drives. That way you can copy/run files from Windows 7 into XPM. You cannot drag & drop files into XPM, maybe future releases will have that feature. Make a folder on one of your Windows 7 local drives and put there a copy of .NET 2.0 and Windows PowerShell 1.0. Install .NET and then install PowerShell 1.0.

Now for a little gotcha. Someone at Microsoft decided to block PowerShell and PowerShell ISE (and a bunch of other applications), XPM won’t publish their shortcuts to Windows 7 start menu. You’ll need to delete the ‘PowerShell’ values so XPM can publish their shortcuts.

I want to thank MVP Charlie Russel for sharing this tip with me!

 

Launch PowerShell 1.0 and create a profile. I had some issues when I tried to launch PowerShell 1.0 with no profile, for some reason it ran my Windows 7 profile.

EDIT: You can force XPM PowerShell to load your v1 profile if you disable the “Drives” sharing in ‘Integration Features’ (Tools | Settings…)

ics

 

Now close the VM by pressing the X button (you may need to reboot the VM, press CTRL+ALT+DEL at the top menu and then press the Shutdown button).

Take a look at Windows 7 start menu, XPM will (hopefully) publish PowerShell shortcuts :-), you should see something like the following:

As you can see all of PowerShell’s shortcuts were published except for PowerShell itself. In this case launch XPM again and copy the PowerShell shortcut under ALLUSERS profile.

Close the VM (you may have to reboot it again) and check if the shortcut was published.

OK, now click the ‘Windows PowerShell (Virtual Windows XP 1)’ shortcut, you’ll probably get this dialog:

Click ‘Open Virtual Application’, this will launch PowerShell 1.0 in seamless mode, here’s a screenshot of my desktop showing both versions of PowerShell running on the same machine:

Isn’t that great!

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

6 comments

  1. Alan RenoufMay 12, 2009 ב 19:41

    Thats great, a nice way of doing it, thanks for blogging this.

    Alan

    Reply
  2. tsahiMay 13, 2009 ב 00:18

    One is left to wonder, why would you want PowerShell 1.0 when you have PowerShell 2.0?

    Reply
  3. ScriptFanaticMay 13, 2009 ב 11:54

    Hi Tsahi, several Reasons:

    1. It’s good to have access to both 🙂
    2. v1 is the official release, v2 is still in development.
    3. When you need to test scripts on v1 (though v2 is compatiable with v1, http://blogs.msdn.com/powershell/archive/2009/05/06/powershell-v2-backward-compatibility.aspx), especially if you are an active guy in PowerShell community (answering questions on forums etc)
    4. Some 3rd tools are not V2 approved.

    Reply
  4. Jean LouwJune 25, 2009 ב 11:52

    Thanks Shay, this is brilliant!

    Reply
  5. lsAugust 28, 2009 ב 02:37

    Do you know why Powershell 2.0 still installs into C:\Windows\System32\WindowsPowerShell\v1.0?

    Why the v1.0 folder and not v2.0?

    Reply
  6. ScriptFanaticAugust 30, 2009 ב 18:07

    In my opinion the reason is to maintain backwards compatibility. In the below blog post (last bullet) Jeffrey Snover explains why they have decided to keep using ps1 script extensions instead of ps2 in v2, so I guess we can assume the same for the folder name.

    http://blogs.msdn.com/powershell/archive/2007/11/02/ctp-versioning.aspx

    Reply