During today’s Management Masters I did a demo on how and why to use application wrappers, in one of the demos I showed a function called Invoke-Exe and I thought I did publish that long time ago, but I did not, so here it is. Actually, there is two versions of this. One that always return the exit code from the app and then you can use that for conditioning, the other one checks that the return code is what you told it to be and if not it throws an error.
Invoke-EXE – Version 1
Invoke-EXE – Version 2
How to use them?
You can import them as modules and then execute (since they have the same function name, you cannot run them at the same time. If you nned to just rename one of the functions, or just use the function as a part of your script)
For version 1:
Invoke-EXE –Executable setup.exe –Arguments “/silent” –SuccessfulReturnCode 0
For version 2
Invoke-EXE –Executable setup.exe –Arguments “/silent”
or
Invoke-EXE –Executable setup.exe
/mike
Categories: Deployment, PowerShell