From 291f01045b0d57e0381d921bbc9040fc38ea44c9 Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Wed, 28 May 2014 08:54:36 -0700 Subject: [PATCH] Fixed issue 3918 Running Windows guest commands through a scheduled task were not returning the correct exit codes, they were only returning 1 or 0. This has negative consequences especially for Puppet which can return an exit code of 2 for partial success. Since we're running an executable from inside a powershell encoded command we need to ensure we explicitly propagate the exit code to the original caller just like a regular PowerShell script - in this case cmd /c which in return is called from a scheduled task. --- plugins/communicators/winrm/scripts/elevated_shell.ps1.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb b/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb index 241993f03..454e5e874 100644 --- a/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb +++ b/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb @@ -1,4 +1,4 @@ -$command = "<%= options[:command] %>" +$command = "<%= options[:command] %>" + '; exit $LASTEXITCODE' $user = '<%= options[:username] %>' $password = '<%= options[:password] %>'