-2

我有一个 powershell 脚本,它使用以下标头拉入服务器列表。计算机名称,操作类型,操作名称。然后我循环遍历,如果我有服务器、服务、服务名称的格式,则启动/停止服务。如果我有 server,script,script_path_name 的格式,那么我正在尝试使用调用命令来运行该脚本。但是我需要以某种方式建立一个远程会话......这是我得到的错误 txt。

[c1399] 连接到远程服务器 c1399 失败并显示以下错误消息:客户端无法连接到请求中指定的目标。验证目标上的服务是否正在运行并且正在接受请求。请查阅在目标(最常见的是 IIS 或 WinRM)上运行的 WS-Management 服务的日志和文档。如果目标是 WinRM 服务,在目标上运行以下命令来分析和配置 WinRM 服务:“winrm quickconfig”。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。+ CategoryInfo:OpenError:(c1399:String)[],PSRemotingTransportException + FullyQualifiedErrorId:CannotConnect,PSSessionStateBroken

这是我正在使用的当前代码...

elseif($computer.optype -eq "script")
{      
    write-host  running script $computer.opname on $computer.computername  
    $Status = Invoke-Command -ComputerName $computer.computername -ScriptBlock { . $computer.opname }
    Write-Output "Script execution status for $($computer.name) is $Status" >> C:\Scripts\RMLog.txt
}
4

1 回答 1

0

在服务器上启用电源外壳远程处理。要启用 PowerShell 远程处理,请运行以下命令,

启用-PSRemoting -Force

请参阅以下链接了解更多详情 http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/

http://powershelltutorial.net/V2/Powershell-With-TFS

这将解决你的问题..

于 2013-09-27T13:35:02.923 回答