powershell - Import-PSSession : Proxy creation has been skipped for '%' command,,因为PowerShell无法验证其名称的安全性

标签 powershell powershell-2.0 powershell-remoting

我有一个SharePoint服务器场设置,并且正在使用远程Powershell从域中的Windows 7计算机连接到我的其中一个应用程序/搜索服务器。客户端服务器和应用程序服务器都具有Powershell 2,其执行策略设置为Unrestricted,并且启用了psremoting。此外,我将cmdlet作为域管理员帐户运行。

我可以使用以下cmdlet创建到远程服务器的 session :

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

但是,当我导入 session 时,出现以下错误:
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

谁能帮助解决此错误?

最佳答案

我通过简单地输入远程 session 而不是导入它来解决了这一问题。然后,我能够添加安装在远程计算机上的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()

另一个选择是将Invoke-Command cmdlet与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()

关于powershell - Import-PSSession : Proxy creation has been skipped for '%' command,,因为PowerShell无法验证其名称的安全性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11801433/

相关文章:

powershell - 使用 cake-build 执行远程 powershell 脚本的问题

xml - Powershell 编辑 Xml 导致 Visual Studio 报告行尾不一致

c# - 从 C# 环境向 powershell 脚本文件传递参数

SharePoint 2010 - 更改 SiteCollection URL

powershell - 我如何使用 powershell 进行用户转储

powershell - Invoke-command -ArgumentList 参数语法

powershell - 使用 PowerShell 将多个 CSV 文件合并为一个

powershell - 动态参数取默认值

sql-server - SQL Server 代理作业的 Powershell 无法识别 ConvertTo-CSV

powershell - 在函数中调用时导入 PSSession 错误