diff --git a/plugins/communicators/winssh/communicator.rb b/plugins/communicators/winssh/communicator.rb index 3ea012f6185..21cad5863a9 100644 --- a/plugins/communicators/winssh/communicator.rb +++ b/plugins/communicators/winssh/communicator.rb @@ -44,7 +44,7 @@ def shell_execute(connection, command, **opts) stderr_data_buffer = '' @logger.debug("Base SSH exec command: #{command}") - command = "$ProgressPreference = 'SilentlyContinue';Write-Output #{CMD_GARBAGE_MARKER};[Console]::Error.WriteLine('#{CMD_GARBAGE_MARKER}');#{command}" + command = "$ProgressPreference = 'SilentlyContinue';Write-Output #{CMD_GARBAGE_MARKER};[Console]::Error.WriteLine('#{CMD_GARBAGE_MARKER}');#{command};$?" ch.exec(command) do |ch2, _| # Setup the channel callbacks so we can get data and exit status @@ -96,6 +96,9 @@ def shell_execute(connection, command, **opts) # probably done. This fixes up issues with hanging. ch.close end + + # Send eof to let server know we're done + ch2.eof! end end