Run a Console Application With PowerShell

I have a DbUp console application that needed to be executed with PowerShell (in my case via Octopus Deploy – but this works in any case), but I wanted to be able to get the result when executing it. By default, running the “Database.exe” from PowerShell will open a new console window for the application to run, return immediately, and leave you with no output or error codes.

To solve this, you can use Start-Process with a few flags in order to get the output written into your PowerShell window, and to wait for completion before getting the exit code:

$databaseProcess = Start-Process Database.exe -PassThru -Wait -NoNewWindow

exit $databaseProcess.ExitCode