PowerShell execute external command in same window
powershell
Solution
Does this work for you?
$outcome = Invoke-Expression "cmd.exe /c dir"
$outcome
Problem
I am trying to execute an external command using powershell, without having the second program to popup, I need to execute this program within the same PowerShell window and output both the log and the errors. I started with this: ``` $outcome = Start-Process -Wait -FilePath "cmd.exe" -ArgumentList "dir" -NoNewWindow 2>&1 $outcome ``` But it doesn't work as expected. I still see the new window popping up with DOS and no redirect at all about the output, the errors and so on. Am I doing something wrong?