Invoke-PowerShell should support CLR2 with PowerShell 3

Issue #104 resolved
Jason Stangroome
created an issue

In PowerShell v3, powershell.exe supports a "-version" argument.

Running "powershell.exe -version 2.0" will start PowerShell under CLR 2.

However, due to CLR2 and CLR4 having in different GACs, PowerShell 3 running under CLR2 which actually load the PowerShell v2 language assemblies and modules.

So, while requesting CLR2 under PSv3 may warrant a warning that some v3 language features and cmdlets won't be available, it should not throw an error preventing use of CLR2 as this is occasionally required to interact with third-party CLR2 components.

Comments (2)

  1. Aaron Jensen repo owner

    powershell's -Version parameter doesn't support script blocks. Try this:

    powershell -version 2 -Command { $PSVersionTable }

    You'll notice an error message that powershell doesn't support the -Version parameter. Before actually calling the powershell executable, it looks like the command is converted to an encoded command, then passed to a new powershell process. When passing an encoded command, you can't use the -Version parameter.

  2. Aaron Jensen repo owner

    Fixes issue #104: Invoke-PowerShell should support CLR2 with PowerShell 3.

    It turns out if you run a script instead of a script block, you can run that script under CLR2. I updated Invoke-PowerShell to take in a FilePath of a script to run.

    → <<cset 39f7a8b029b1>>

  3. Log in to comment