gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:06:47 26 4
gpt4 key购买 nike

我有一个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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com