powershell.exe -version parameter

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Max Kozlov Max Kozlov 3 months, 1 week ago.

  • Author
    Posts
  • #64177
    Profile photo of The PowerShell Bear
    The PowerShell Bear
    Participant

    This seems to be a "feature" of PowerShell that the -version parameter only seems to work for version 2.0. Does anybody know why that is? Right now, my workstation has v5.0 installed on it, but the servers I'm writing to have v4.0, and I've run into some bugs when I tried to use something I was unaware was new in 5.0, and it would be useful to be able to test the downlevel version without having to throw it up to a server.

    Any ideas?

    Anyone know the thought process behind not supporting that?

  • #64191
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    Documentation – https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help

    -Version
    Starts the specified version of Windows PowerShell. The version that you specify must be installed on the system. If Windows PowerShell 3.0 is installed on the computer, valid values are "2.0" and "3.0". The default value is "3.0".

    If Windows PowerShell 3.0 is not installed, the only valid value is "2.0". Other values are ignored.

    May have to stick with development of the script on the servers to ensure you're not using Modules or features not in v5 or ISE Steriods has a code compatibility validator that can check code from multiple versions. Not sure if Sapien's Powershell Studio has comparable features.

  • #64210
    Profile photo of The PowerShell Bear
    The PowerShell Bear
    Participant

    I'm not really keen on spending money on an ISE module, especially when I almost never use the ISE and don't really care for it overall (I much prefer VS Code).

    I definitely don't want to spend almost $400 on PowerShell Studio, when the main attraction of it is building GUIs in the outdated WinForms technology (and it's only a matter of time before the Visual Studio addon works with GUIs as well, and that has a free Community edition I can mess around in and also works for C#).

    I was mostly just hoping someone might know why only 2.0 seems to be supported as a launchable downlevel version. I can continue testing on a server for this, but I was hoping I wouldn't have to.

  • #64225
    Profile photo of Max Kozlov
    Max Kozlov
    Participant

    afaik it's was implemented for exchange and sharepoint which require v2 because of modules that require exact .net version
    v2 = .net2

You must be logged in to reply to this topic.