Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-60) fix upgrade/installation Filestream errors on PSv2
Powershell version 2, has several issues in handling output redirection This is best documented here: https://connect.microsoft.com/PowerShell/feedback/details/587165/ powershell-double-redirection-problem Another obscure bug that occurs in powershell is here. https://connect.microsoft.com/PowerShell/feedback/details/371321/ benign-errors-for-missing-closing-are-left-in-the-error-variable These 2 issues are compounded in the provider, because the benign error sent to $error, then triggers the double redirection issue within puppet. This will automatically fail the resource. This patch is confined to Powershell v2 (Win2008r2/Win7) and essentially captures the output from running chocolateyInstall.ps1 via a variable. We can now see the errors that are thrown instead of the FileStream errors in a log stored here: $env:TEMP\chocoError.log While this may cause a false positive success to be returned to puppet, IMHO this is better than a false failure, based on upstream legacy bugs to be returned, particularly because of the transparency around the $error content. This fix leaves the existing logic intact for Powershell versions >2 as I have not observed. Additionally write-host calls were switched to write-output as a best practice to avoid observed Filestream errors within this edge case. The recommendation to avoid this scenario altogether on Win2008r2 is to install .NET 4.5 and then WMF 4.0, or use Win2012+
- Loading branch information