Start PowerShell ISE with the 2.0 runtime

谁说胖子不能爱 提交于 2019-12-04 02:45:46

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!