10

SharePoint ファームのセットアップがあり、リモート PowerShell を使用して、ドメイン内の Windows 7 マシンからアプリケーション/検索サーバーの 1 つに接続しています。クライアント サーバーとアプリケーション サーバーの両方に、実行ポリシーが無制限に設定され、psremoting が有効になっている powershell 2 があります。さらに、ドメイン管理者アカウントとしてコマンドレットを実行しています。

次のコマンドレットを使用して、リモート サーバーへのセッションを作成できます。

$Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos" 
Import-PSSession $Session -AllowClobber

ただし、セッションをインポートすると、次のエラーが発生します。

Import-PSSession : Proxy creation has been skipped for '%' command, because PowerShell couldn't verify its name as safe.
At line:1 char:17
+ Import-PSSession <<<<  $Session -AllowClobber
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], InvalidOperationException
    + FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Import-PSSession : Proxy creation has been skipped for '?' command, because PowerShell couldn't verify its name as safe.
At line:1 char:17
+ Import-PSSession <<<<  $Session -AllowClobber
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], InvalidOperationException
    + FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Import-PSSession : Could not resolve remote alias 'ise'.
At line:1 char:17
+ Import-PSSession <<<<  $Session -AllowClobber
    + CategoryInfo          : OperationTimeout: (:) [Import-PSSession], ArgumentException
    + FullyQualifiedErrorId : ErrorCouldntResolveAlias,Microsoft.PowerShell.Commands.ImportPSSessionCommand

誰でもこのエラーを解決できますか?

4

2 に答える 2

8

リモートセッションをインポートする代わりに、単にリモートセッションに入ることでこれを解決しました。その後、リモート マシンにインストールされた SharePoint スナップインを追加して、スクリプトを実行することができました。

$Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos" 
Enter-PSSession $Session
Add-PSSnapin Microsoft.SharePoint.PowerShell

<Cmdlets or script goes here>

Exit-PSSession
Remove-PSSession -ID $Session.ID
[GC]::Collect()

もう 1 つのオプションは、Invoke-Command コマンドレットを ScriptBlock パラメーターと共に使用することです。

$Session = New-PSSession -ConfigurationName Microsoft.PowerShell -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication Kerberos
Invoke-Command -Session $Session -ScriptBlock { Add-PSSnapin Microsoft.SharePoint.PowerShell }

Invoke-Command -Session $Session -ScriptBlock { <Your cmdlet here.> }

Remove-PSSession -ID $Session.ID
[GC]::Collect()
于 2012-08-06T14:02:49.953 に答える
1

エラーは、リモート サーバーからコマンド セット全体をインポートしようとしていることです。クロバーを許可している理由がよくわかりません。

個人的には、すべてのリモート ワークスペースではなく、関連する SHarePoint モジュールをインポートするだけです。

インポートは機能しますか??

于 2012-08-04T12:55:08.230 に答える