Start PowerShell ISE with the 2.0 runtime

前端 未结 2 2239
暗喜
暗喜 2021-02-20 13:24

When PowerShell 3.0 is installed, I can force PowerShell to start using the version 2.0

-Version
    Starts the specified version of Windows PowerShell.
    Ente         


        
相关标签:
2条回答
  • 2021-02-20 13:52

    Tweaking the config file won't help, powershell_ise.exe definitely depends on .Net V4. It also depends heavily on the V3 version of the PowerShell engine.

    There is no supported way to run V2 of the PowerShell ISE after PowerShell V3 is installed. Unlike the core PowerShell binaries (like System.Management.Automation.dll) I think the V2 ISE binaries are either overwritten or removed as part of the V3 installation.

    I'm afraid you'll have to run your script from powershell.exe.

    0 讨论(0)
  • 2021-02-20 14:02

    You can run 2.0 runtime command by creating new PSSession.

    Register-PSSessionConfiguration -Name PS2 -PSVersion 2.0 –ShowSecurityDescriptorUI
    
    # Please consult system admin when your run set-item and Enable-WSManCredSSP command
    Set-Item wsman:localhost\client\trustedhosts -value * -Confirm:$false -Force
    Enable-WSManCredSSP -Role Client –DelegateComputer * -Force
    Enable-WSManCredSSP -Role Server -Force
    
    # For test purpose
    # Get-WSManCredSSP
    # get-item wsman:localhost\client\trustedhosts
    
    $cred = Get-Credential
    $session = New-PSSession -ComputerName $env:COMPUTERNAME -authentication credssp -ConfigurationName PS2 -Credential $cred
    Enter-PSSession $session
    
    # 2.0 runtime
    Add-PSSnapin microsoft.sharepoint.powershell
    $web = Get-SPWeb http://SPSite/
    $web.Url
    
    Exit-PSSession
    
    Unregister-PSSessionConfiguration -Name PS2
    
    Disable-WSManCredSSP -Role Client
    Disable-WSManCredSSP -Role Server
    

    If you don't exit PSSession, you can run 2.0 runtime command from Powershell ISE 3.

    0 讨论(0)
提交回复
热议问题