Running remote commands using winrm and timeout

MrFlinstone 416 Reputation points

Hi All.

We are calling winrm commands from a remote host (ansible), and the issue we are having is the host being in a stuck state and the batch server is also stuck for hours/days. The root cause of these issues appears to be the bad health of the target server, it could be memory, page file or general health stability. When we have had a similar issue from ansible and the a PS remoting command executed from a Ps shell, I got the error below.

The request for the Windows Remote Shell with ShellId 0000000-1D4F-4GYY-55BB-D98DFDKJ348J failed because the shell
was not found on the server. Possible causes are: the specified ShellId is incorrect or the shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation. For more information, see the about_Remote_Troubleshooting Help
    + CategoryInfo          : OpenError: (SERVERNAME.domain:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : CannotConnectTargetSessionDoesNotExist,PSSessionStateBroken 

Is there a way to force a timeout on wrm so that the session can be aborted and exit procedures triggered ?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,766 questions
No comments
{count} votes