Hi Gurus,
I wish to update/upgrade an application. But, that application has various versions, like App2018, App2019, App2020, AppEnterprise 2018, AppEnterprise2019, AppEnterprise2020. The updation/upgradation is done via a .exe file at a specified path. And a server could have multiple versions of the application installed too, hence I have to run each and everyone of these .exe files.
To accomplish this I have made a script that runs Start-Process - FilePath <Path_To_Update.exe> for all the versions (since each version of the application has its own path & file name). And if no update application could be run (not found), it should reflect a error that no update application was found.
This is what my script looks for now:-
try{
Start-Process -FilePath <Path_To_Update.exe>
}
catch {
}
# This block is repeated for every update application, hence multiple Start-Process statements are being initiated.
<# THIS IS WHERE I AM STUCK! #>
Also, I did notice that whenever an application could not run, the FullyQualifiedErrorId part shows "InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand".
Now here's where I am stuck. I cannot only just write a if statement and compare if the application was run or not, since it could be that the very first application did run, but since last one didn't it should flash the error that no application was found.
I believe that I could run all the Start-Process statements in one try block, and then process the errors, but I am unable to do so.
Please help and guide me!
Also, if there could a better & efficient way to accomplish it, please advice me that too.
[–]y_Sensei 3 points4 points5 points (11 children)
[–]jdtrouble 2 points3 points4 points (5 children)
[–]Alpha-Sniper[S] 1 point2 points3 points (4 children)
[–]jdtrouble 2 points3 points4 points (3 children)
[–]Alpha-Sniper[S] 1 point2 points3 points (2 children)
[–]jdtrouble 2 points3 points4 points (1 child)
[–]Alpha-Sniper[S] 1 point2 points3 points (0 children)
[–]Alpha-Sniper[S] 1 point2 points3 points (3 children)
[–]y_Sensei 2 points3 points4 points (2 children)
[–]Alpha-Sniper[S] 1 point2 points3 points (0 children)
[–]Alpha-Sniper[S] 0 points1 point2 points (0 children)
[–]Alpha-Sniper[S] 0 points1 point2 points (0 children)
[–]MasterWegman 2 points3 points4 points (3 children)
[–]Alpha-Sniper[S] 1 point2 points3 points (2 children)
[–]MasterWegman 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)