Wondering the way to pass a console application output from cmd.exe to Powershell for further manipulation without a temp file.
Example:
cmd /c SET | powershell -command Write-Host -f Green $_
Expectation: the green-colored SET's output.
Wondering the way to pass a console application output from cmd.exe to Powershell for further manipulation without a temp file.
Example:
cmd /c SET | powershell -command Write-Host -f Green $_
Expectation: the green-colored SET's output.
If you want to pipe the output from an executable from within powershell, simply pipe directly to a function:
cmd /c SET |Write-Host -ForegroundColor Green
If you want to pipe output to powershell.exe from cmd.exe:
SET |powershell -Command "$input |Write-Host -ForegroundColor Green"
Alternatively, grab the environment variables directly from PowerShell's env:
drive, no need to invoke cmd
:
Get-ChildItem env: |Out-String |Write-Host -ForegroundColor Green