在 Linux 上找不到 PowerShell 7.2.1 New-PSSessionOption OperationTimeout

PowerShell 7.2.1 New-PSSessionOption OperationTimeout cannot be found on Linux

对于 PS 7.2.1,对 Windows 和 Linux 的相同调用 return 得到了不同的结果,

New-PSSessionOption -OperationTimeout 360000

在 Windows 上,它 return 编辑了一个参数和值列表,正确设置了 OperationTimeout,00:06:00。

但是在 Linux 它失败了,显示以下错误:

New-PSSessionOption: A parameter cannot be found that matches parameter name 'OperationTimeout'.

怎么了?

在 Linux 上,如果我只发出“New-PSSessionOption”,w/o 任何参数,它将 return 具有默认值的参数列表,包括“:OperationTimeout:00:03:00”。所以,它在实现中,但为什么我不能设置它?

顺便说一句,我试图复制许多大小不一的文件,从 Linux 到 Windows。但是在 Copy-Item 运行 几分钟后,它开始失败并显示“解析 Wsman 错误消息的内部错误...”。这就是为什么我想将此超时设置得更长一些。

考虑到 OperationTimeout doesn't do what its name suggests:

,也许您不需要解决您的问题

OperationTimeout does not impose a time limit on commands or processes running in a remote session and does not affect other remoting protocols like SSH.

简而言之:

  • This comment on GitHub 详细说明了此设置实际控制的内容:它与远程计算机响应接收请求所需的时间有关,但 PowerShell 只是在发生请求时静静地重试暂停。 tl;dr 是:-OperationTimeout 影响“几乎没有”。可以说,它不应该暴露给最终用户。

  • 实现实际的 operation-duration 超时是 GitHub proposal #5434 的主题,建议将 -Timeout 参数添加到 Invoke-Command


关于您的症状:

  • 这可能是一个错误,因为即使 OperationTimeout 特定于 WS-Man/WinRM, the remoting protocol used on Windows, you could still be trying to remote into a Windows machine, and the New-PSSessionOption doesn't require you to commit to a protocol - only when you call New-PSSession,您是否承诺了一个协议,例如选择 SSH-based 远程处理通过-SSHTransport.

  • 也就是说,因为听起来设置适用于 caller 端,可以想象 Linux 和 macOS 实现 WS-Man 可能缺少它。通常,此实现似乎存在问题并且可能没有未来 - 参见 this blog post.