You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ParserError: /ado/_work/_temp/5746ce19-436f-4ddd-bfa1-f3344e169c1e.ps1:7
Line |
##[debug]$LASTEXITCODE: {0}' -f $LASTEXITCOD …
| ~~~~~~~~~~~~~~
| Variable reference is not valid. ':' was not followed by a valid
| variable name character. Consider using ${} to delimit the name.
if (!(Test-Path-LiteralPath variable:LASTEXITCODE)) {
Write-Host'##vso[task.debug]`$LASTEXITCODE is not set.'#NOTE : see the backtick before $
} else {
Write-Host ('##vso[task.debug]`$LASTEXITCODE: {0}'-f$LASTEXITCODE)
exit$LASTEXITCODE
}
Environment type (Please select at least one enviroment where you face this issue)
Self-Hosted
Microsoft Hosted
VMSS Pool
Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
n/a
Operation system
Ubuntu 22.04.5 LTS
Relevant log output
##[debug]/usr/bin/pwsh arg: . '/ado/_work/_temp/5746ce19-436f-4ddd-bfa1-f3344e169c1e.ps1'
2025-02-20T04:55:36.3422666Z ##[debug]exec tool: /usr/bin/pwsh
2025-02-20T04:55:36.3422794Z ##[debug]arguments:
2025-02-20T04:55:36.3422909Z ##[debug] -NoLogo
2025-02-20T04:55:36.3423026Z ##[debug] -NoProfile
2025-02-20T04:55:36.3423147Z ##[debug] -NonInteractive
2025-02-20T04:55:36.3423259Z ##[debug] -Command
2025-02-20T04:55:36.3423391Z ##[debug] . '/ado/_work/_temp/5746ce19-436f-4ddd-bfa1-f3344e169c1e.ps1'
2025-02-20T04:55:36.3423516Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command .'/ado/_work/_temp/5746ce19-436f-4ddd-bfa1-f3344e169c1e.ps1'
2025-02-20T04:55:36.5551031Z �[31;1mParserError: �[0m/ado/_work/_temp/5746ce19-436f-4ddd-bfa1-f3344e169c1e.ps1:7�[0m
2025-02-20T04:55:36.5551386Z �[31;1m�[0m�[36;1mLine |�[0m
2025-02-20T04:55:36.5551846Z ##[debug]�[36;1m$LASTEXITCODE:�[0m {0}' -f $LASTEXITCOD …�[0m
2025-02-20T04:55:36.5552067Z �[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m | �[31;1m ~~~~~~~~~~~~~~�[0m
2025-02-20T04:55:36.5552256Z �[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m | �[31;1mVariable reference is not valid. ':' was not followed by a valid�[0m
2025-02-20T04:55:36.5552456Z �[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m�[31;1m�[36;1m | �[31;1mvariable name character. Consider using ${} to delimit the name.�[0m
2025-02-20T04:55:36.5664793Z
2025-02-20T04:55:36.5666859Z ##[debug]Exit code 1 received from tool '/usr/bin/pwsh'
2025-02-20T04:55:36.5669029Z ##[debug]STDIO streams have closed for tool '/usr/bin/pwsh'
2025-02-20T04:55:36.5673436Z ##[debug]task result: Failed
2025-02-20T04:55:36.5685235Z ##[error]PowerShell exited with code '1'.
New issue checklist
Task name
PowerShell@2
Task version
2.247.1
Issue Description
I am using the PowerShell@2 task to execute a script with arguments as shown below.
The task always fails with:
The generated script in the temp folder is:
You need to escape
$LASTEXITCODE
eg.Environment type (Please select at least one enviroment where you face this issue)
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
n/a
Operation system
Ubuntu 22.04.5 LTS
Relevant log output
Full task logs with system.debug enabled
Repro steps
The text was updated successfully, but these errors were encountered: