I\'m invoking a PowerShell script from MSBuild. MSBuild is able to capture the output returned, but thinks the project is built successfully.
The problem is that th
Add exit $lastexitcode to test.ps1
After comment:
Try this in test.ps1:
trap {Write-Host -foreground red $_.Exception.Message; exit 1; continue} Invoke-command {Powershell.exe C:\a.ps1} -computername $computers
Basically, I don't think MSBuild is at fault here.
I tried your wrong Invoke-Command and the $lastexitcode was set to 0 even though the Invoke-Command had failed! You can test whether this works or not from cmd itself by doing echo %errorlevel% and see you get 1.