为什么在远程计算机上使用 PowerShell 调用 Get-Service 时出现"Get-WindowSize"未实现错误?



我有一台Windows 10主机连接到托管在同一机器上的Hyper-V Windows 10 VM。 我一直在关注Pluralsight PowerShell教程。 我正在尝试在远程计算机上获取可用的服务。

我可以使用以下命令在远程计算机上启动会话:

Enter-PSSession -ComputerName Client1 -Credential username

会话启动并连接后,我尝试调用 Get-Service 来标识客户端计算机上的服务。

[Client1]: PS C:UsersusernameDocuments>Get-Service

当我运行上述命令时,我收到以下错误消息:

未实现远程主机方法get_WindowSize。 + 类别信息 : 资源不可用: (:) [out-lineoutput], PSRemotingDataStructureException + FullQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Command.OutLineOutputCommand

我在主机和客户端计算机上运行相同版本的PowerShell(5.1.18362.145(。 我认为这在某种程度上是客户端计算机上的问题?

[Client1]: PS C:\Users\username\Documents>Get-Service | out-string

这应该有效,可能是PowerShell或新版本Windows 10的错误

。其他链接 : https://social.technet.microsoft.com/Forums/en-US/67142783-2acd-4d54-aef2-8d89d71457c5/powershell-remoting-broken-in-windows-10-1903?forum=winserverTS

"Remote host method get_WindowSize is not implemented."

这发生在客户端以Powershell_ISE开头的所有远程会话。 Out-String 的解决方法很糟糕,它会破坏该调用的结果对象。 到目前为止,最好的解决方法是不使用ISE或将远程过程嵌入脚本并使用Powershell调用它.exe

真烦人...并且现在还没有修复。

解决方法示例:您可以使用:$YourServices=Invoke-command -ComputerName <computername> -ScriptBlock {get-service},而不是使用enter-pssession然后请求运行服务的结果。然后,您的对象$YourServices中拥有所有服务统计信息。

最新更新