当我打开远程PowerShell会话并且TCP停止工作(例如电源关闭/电缆断开/ ...)时,Invoke-Command或Remove-PSSession命令阻塞了几分钟,试图重新连接。
我想将此超时减少到5秒。
在Invoke-Command上,我得到警告
WARNING: The network connection to 192.168.30.106 has been interrupted. Attempting to reconnect for up to 4 minutes...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: Attempting to reconnect to 192.168.30.106 ...
WARNING: The reconnection attempt to 192.168.30.106 failed. Attempting to disconnect the session...
WARNING: Computer 192.168.30.106 has been successfully disconnected.
Invoke-Command : Network connectivity to 192.168.30.106 has been lost and the reconnection attempt failed. Please repair the network connection and reconnect using Connect-PSSession or
Receive-PSSession.
At line:4 char:1
+ Invoke-Command -Session $remoteSession -ScriptBlock {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationTimeout: ([PSSession]Session7:PSSession) [Invoke-Command], RuntimeException
+ FullyQualifiedErrorId : PowerShellNetworkFailedStartDisconnect,Microsoft.PowerShell.Commands.InvokeCommandCommand
Remove-PSSession似乎使用了不同的超时时间(大约100秒)。
OpenTimeout,OperationTimeout,IdleTimeout和CancelTimeout似乎都不会影响这些超时。
我想我需要一些较低级别的超时选项。那存在吗?