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:

  1. pipe output of cmd variable doesn't write host
  2. only if $succeeded eq $true, write-host output variable cmd

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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -