Fix Wait-Process compatibility with PowerShell 5.1 (#40263)
Wait-Process -PassThru is only available in PowerShell 7+. Since test.bat invokes powershell.exe (Windows PowerShell 5.1), this caused a NamedParameterNotFound error when running tests. Replace with Wait-Process followed by reading ExitCode from the process object already returned by Start-Process -PassThru. Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ben Hillis committed
Apr 21, 2026 at 21:58 UTC
8897d64c6bdaf3e71179cebc245cb0fb7c5c9728
1 file changed
+2
-1
tools/test/run-tests.ps1
+2
-1
@@ -95,4 +95,5 @@ if ($AttachDebugger)
95
Start-Process "WinDbgX.exe" -ArgumentList "-p $($teProcess.Id)"
96
}
97
98
-exit ($teProcess | Wait-Process -PassThru).ExitCode
98
+$teProcess | Wait-Process
99
+exit $teProcess.ExitCode