I just published a new article. Last week, I was executing a PowerShell script from a .Net application. This is something I already wrote about back in June 2018.
I still use something like this in my apps. But this time, I want to be able to run a script that is persisted on disk and, even more important, to be able to get the exit code of my script into my .Net application.
Of course PowerShell has the Exit statement but the code is not easily read by a .Net application.
You can read the full article from https://www.emoreau.com/Entries/Articles/2020/11/Getting-an-exit-Code-returned-by-a-PowerShell-script-from-Net-app.aspx.