From f9abca0bd7ece7680ad508aa77362d434df69958 Mon Sep 17 00:00:00 2001 From: Matthew Bradbury Date: Wed, 26 Nov 2025 12:04:42 +0000 Subject: [PATCH] Check LASTEXITCODE is set before checking its value --- provisioner/powershell/provisioner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index ea54c7576..444a38111 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -55,7 +55,7 @@ const wrapPowershellString string = ` $exitCode = 1 } - if ($LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0) { + if ((Test-Path variable:global:LASTEXITCODE) -and $LASTEXITCODE -ne $null -and $LASTEXITCODE -ne 0) { $exitCode = $LASTEXITCODE } exit $exitCode