diff --git a/lib/winrm/shells/power_shell.rb b/lib/winrm/shells/power_shell.rb index 696ede9f..4d6fb196 100644 --- a/lib/winrm/shells/power_shell.rb +++ b/lib/winrm/shells/power_shell.rb @@ -30,6 +30,9 @@ class Powershell < Base class << self def close_shell(connection_opts, transport, shell_id) + return false unless Thread.current.alive? + + Thread.current.wakeup if Thread.current.status =~ /sleep/ msg = WinRM::WSMV::CloseShell.new( connection_opts, shell_id: shell_id,