10

PowerShell 3.0 がインストールされている場合、バージョン 2.0 を使用して PowerShell を強制的に起動できます。

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

これは、.Net Framework V 4 (SharePoint!) をサポートしていないスナップインで役立ちます。

PowerShell ISEに相当するものはありますか?

実行しようとしましたpowershell_ise.exe -version 2.0が、これは機能しません。

実行powershell_ise.exe -helpしても、私のニーズを満たすパラメータは表示されません。

4

2 に答える 2

9

構成ファイルを微調整しても役に立ちません。powershell_ise.exe は確実に .Net V4 に依存しています。また、PowerShell エンジンの V3 バージョンにも大きく依存しています。

PowerShell V3 のインストール後に PowerShell ISE の V2 を実行する方法はサポートされていません。コア PowerShell バイナリ (System.Management.Automation.dll など) とは異なり、V2 ISE バイナリは V3 インストールの一部として上書きまたは削除されると思います。

残念ながら、powershell.exe からスクリプトを実行する必要があります。

于 2013-09-23T23:53:13.117 に答える
2

新しい PSSession を作成することで、2.0 ランタイム コマンドを実行できます。

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

PSSession を終了しない場合は、Powershell ISE 3 から 2.0 ランタイム コマンドを実行できます。

于 2016-02-29T16:54:18.287 に答える