Switch between PowerShell versions

You’ve installed PowerShell V3 (and that’s a good thing!) but you have to test a script to be sure it will run properly on a PowerShell V2 host. Luckily, we can switch between the two versions. The command to do so is the following:

powershell.exe -Version 2
  1. Before
    ~\powerscripts> $psversion
    3.0
    
  2. After
    ~\powerscripts> powershell.exe -version 2
    ~\powerscripts> $psversion
    2.0
    
  3. Back to the Future
    ~\powerscripts> powershell.exe -version 3
    ~\powerscripts> $psversion
    3.0
    

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top