none
what's up with powershell versions?

    Question

  • The powershell install folder for version 1.0 was C:\Windows\system32\WindowsPowerShell\v1.0\ and script files had .ps1 as their extension. I assumed from this that subsequent versions would appear in \v2.0\ and that the script filenames would have a .ps2 extension.

    Neither happened, perhaps in part to avoid confusion with "playstation 2" commonly referred to as PS2 ;-)

    But seriously, now...

    Had my assumption played out, we might have seen multiple powershell versions on one computer, perhaps using the filetype to determine the engine to be used.

    In retrospect, changing the extention on script files would likely have caused some issues along the way when one upgraded powershell. Too bad they did not settle on a non-numeric file type like, for example, .psh, .ps, .mps, etc.

    The fact that powershell is integrated into the os and linked to .NET may have had some affect on this situation.

    But this is all water under the bridge and of no real consequence, because powershell.exe supports a version switch parameter:

    -Version
    Starts the specified version of Windows PowerShell. Enter a version number with the parameter, such as "-version 1.0".

    Great, so now I can develop v1.0 and v2.0 scripts on a computer installed with v2.0, right?

    You tell me. When I start powershell that way $host.version gives the same version information:


    C:\Users\Al>powershell
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.

    PS C:\Users\Al> $host.version

    Major  Minor  Build  Revision
    -----  -----  -----  --------
    2      0      -1     -1


    PS C:\Users\Al> exit

    C:\Users\Al>powershell -version 1.0
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.

    PS C:\Users\Al> $host.version

    Major  Minor  Build  Revision
    -----  -----  -----  --------
    2      0      -1     -1


    PS C:\Users\Al>

    Also, cmdlets new to version 2.0 (like ConvertTo-csv) are still available when running with -version 1.0.

    So my questions are these:

    1. what actual function, if any, is performed by the -version switch?
    2. is there some way to run a functional version 1.0 of powershell on a computer where version 2.0 is installed?
    3. will things improve with v3.0, or just get more complicated?

    Note that I am supporting a server application whose standard installation includes installing powershell v2.0, but working on a workstation running version 2.0. In addition to developing v2.0 scripts for other environments, I like having the ise available for my use.

    Any comments will be appreciated.

    Friday, October 07, 2011 1:43 AM

Answers

All replies

  • 1. It doesn't work in v2, but works in v3 CTP1, currently in "public beta".

    2. Unsupported, but there's hope: http://portablepowershell.com

    3. Dunno, see #1.


    Friday, October 07, 2011 1:48 AM
    Moderator
  • Thank you Marco for that link, you don't understand the world of opportunities that has opened up in my environment!
    Friday, October 07, 2011 2:36 AM
  • Thanks, Marco. here are a few followup comments:

    1. FWIW, although -version does not do what the documentation says it is supposed to, if you give -version as anything other than what is given by the "PSCompatibleVersion" registry value, powershell.exe v2.0 returns a non-zero error code.

    2. useful for some, but I would probably have less trouble justifying a powershell upgrade on our application server than installing a beta version of a v1 emulator for testing code for a production environment.

    3. Interesting. I assume that v3.0 will handle "-version 2.0" - will it also handle "-version 1.0"?

     

    Friday, October 07, 2011 3:17 AM
  • That ".PS1" extension has bothered me from the moment I first learned about it.

    On 10/6/2011 8:43 PM, Al Dunbar wrote:
     > ...

    Too bad they did not settle on a non-numeric file type like, for example,

    > .psh, .ps, .mps, etc.

    Friday, October 07, 2011 3:54 AM
  • Friday, October 07, 2011 4:08 AM
  • Thanks, Marco. here are a few followup comments:

    1. FWIW, although -version does not do what the documentation says it is supposed to, if you give -version as anything other than what is given by the "PSCompatibleVersion" registry value, powershell.exe v2.0 returns a non-zero error code.

    2. useful for some, but I would probably have less trouble justifying a powershell upgrade on our application server than installing a beta version of a v1 emulator for testing code for a production environment.

    3. Interesting. I assume that v3.0 will handle "-version 2.0" - will it also handle "-version 1.0"?

     

    The help for powershell.exe on v3.0 ( from powershell /?) has the following definition for -version flag:

     

     

    -Version

        Starts the specified version of Windows PowerShell.

        Enter a version number with the parameter, such as "-version 1.0".

     

    But when you do that, it brings up 2.0 only.
    • Edited by manojlds Friday, October 07, 2011 6:20 AM
    Friday, October 07, 2011 6:19 AM
  • Thanks, Marco. here are a few followup comments:

    1. FWIW, although -version does not do what the documentation says it is supposed to, if you give -version as anything other than what is given by the "PSCompatibleVersion" registry value, powershell.exe v2.0 returns a non-zero error code.

    2. useful for some, but I would probably have less trouble justifying a powershell upgrade on our application server than installing a beta version of a v1 emulator for testing code for a production environment.

    3. Interesting. I assume that v3.0 will handle "-version 2.0" - will it also handle "-version 1.0"?

     


    3. No, v3 seems to run side-by-side with v2.  v2 replaces v1, so "-version 1.0" will never work, and that's a doc bug.
    Friday, October 07, 2011 11:23 AM
    Moderator
  • Thanks, Marco. here are a few followup comments:

    1. FWIW, although -version does not do what the documentation says it is supposed to, if you give -version as anything other than what is given by the "PSCompatibleVersion" registry value, powershell.exe v2.0 returns a non-zero error code.

    2. useful for some, but I would probably have less trouble justifying a powershell upgrade on our application server than installing a beta version of a v1 emulator for testing code for a production environment.

    3. Interesting. I assume that v3.0 will handle "-version 2.0" - will it also handle "-version 1.0"?

     


    So I guess the question would be...  Why do you really, really want to run in "v1 mode"?
    Friday, October 07, 2011 11:24 AM
    Moderator
  • I was going to sign in to Connect and submit a bug, but, I cant get in!
     
    good catch manojlds
     

    Justin Rich
    http://jrich523.wordpress.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, October 07, 2011 12:21 PM
  • https://connect.microsoft.com/powershell
    is OK right now from here.
    Please post the issue number when you get it submitted.
    Thx!

    On 10/7/2011 7:21 AM, jrich wrote:

    I was going to sign in to Connect and submit a bug, but, I cant get in!
    good catch manojlds

    Friday, October 07, 2011 12:27 PM
  • I have weird issues with my passport account/PC
     
    RDP works wonders :)
     
    ID: 693559
     
     

    Justin Rich
    http://jrich523.wordpress.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, October 07, 2011 12:37 PM
  • im not sure what you mean by side by side?
     
    there is no traces of a v2 exe or other related files that I've been able to
    tell.
     
    from what I can tell from the docs it was an "upgrade" which means V2 was
    replaced, and I was under the impression that V3 just ran in an
    emulated/restricted mode when you told it the version.
     
    and to answer your other question, I can only think of one reason. someone
    is doing a version check in their script/application and you need to lie to
    it in order to get it to run..
     
    personal, I wont ever run V2 again, so V1 isnt an issue at all...
     
     

    Justin Rich
    http://jrich523.wordpress.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, October 07, 2011 12:40 PM
  • Many of the people I support only have PowerShell V1. I like to make sure my scripts work as expected in V1.

     


    Richard Mueller - MVP Directory Services
    Friday, October 07, 2011 3:33 PM
  • I don’t recall having to reboot for going to PS2, and it’s a windows update
    so its really easy to deploy...
     
    I just don’t understand why people are still on 1.0
     
     

    Justin Rich
    http://jrich523.wordpress.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, October 07, 2011 3:39 PM
  • I don't really really want to stick with V1. I'd rather upgrade to V2 on our application servers, but I don't think that my preference will make a strong enough business case. I'd run scripts from my workstation, unfortunately, the bandwidth between that and the servers is less than ideal. I RDP in to the (virtual) servers, so perhaps the best option would be to request a dedicated virtual workstation in the servers' LAN.

    According to some of the information provided by other responders, the v2 engine is downward compatible with v1-compliant scripts. For those like myself and Richard Mueller it would have been nice to have a v1 emulator that would help ensure we did not inadvertently include code that would not run under v1. That's not the in the cards, so I guess it is case closed.

    Saturday, October 08, 2011 12:31 AM
  • I can only think of one reason. someone is doing a version check in their script/application and you need to lie to it in order to get it to run..
     
    Trouble is, lying will not get powershell to lie on your behalf...
    Saturday, October 08, 2011 12:35 AM
  • very instructive, thanks.
    Saturday, October 08, 2011 12:36 AM