Piping cmd output to variable in PowerShell -
i have following in powershell script:
cmd /c npm run build-release $succeeded = $lastexitcode
what i'd is:
- pipe output of
cmd
variable doesn't write host - only if
$succeeded
eq $true
,write-host
output variablecmd
how can done?
use invoke-expression
:
$output = invoke-expression "cmd /c npm run build-release" $succeeded = $lastexitcode if($succeeded -eq 0) { write-output $output }
Comments
Post a Comment