From f381504a00fa65e609ca4942483881a0aea2416a Mon Sep 17 00:00:00 2001 From: John Snow Date: Wed, 13 Dec 2017 09:26:39 -0500 Subject: Fix issue with Powershell function buffer Issue Fixed: https://github.com/chef/chef-dk/issues/1236 Signed-off-by: John Snow --- distro/powershell/chef/chef.psm1 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/distro/powershell/chef/chef.psm1 b/distro/powershell/chef/chef.psm1 index 1a5e2cc5eb..05fee05e5e 100644 --- a/distro/powershell/chef/chef.psm1 +++ b/distro/powershell/chef/chef.psm1 @@ -236,7 +236,6 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) { throw "Unable to create process [$ArgumentString]. Error code $reason." } - $sb = New-Object System.Text.StringBuilder $buffer = New-Object byte[] 1024 # Initialize reference variables @@ -270,7 +269,7 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) { while ([Chef.Kernel32]::ReadFile($hReadOut, $buffer, $buffer.Length, [ref] $bytesRead, 0)) { $output = [Text.Encoding]::UTF8.GetString($buffer, 0, $bytesRead) if ($output) { - [void]$sb.Append($output) + $output } if ($bytesRead -lt $buffer.Length) { # Partial buffer indicating the end of stream, break out of ReadFile loop @@ -307,9 +306,6 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) { } } - # Return output obtained from child process stdout/stderr - $sb.ToString() - # Cleanup handles $success = [Chef.Kernel32]::CloseHandle($pi.hProcess) if (-Not $success) { -- cgit v1.2.1