I’m relatively new to Powershell and I’m trying to write my first script for practice but I’m also interested in making it somewhat useful (especially as I build on it) for later use. Basically I’m making a script to detail currently installed Windows 10 UWP applications for both the currently logged in user and for all users. I’ve created a simple menu and then, based on the user’s choice, different Powershell code is executed and the results should be displayed.
Here’s the Pastebin of the script as I currently have it:
I’m running into a problem where I’m not getting correct output as I go through the various menu options. The first time the script is run, and I choose one of the menu options, the script seems to output the correct information for that one selected option. However, on subsequent menu options choices while in the same script/Powershell session, I’m not getting accurate output. It is almost as if the Powershell session is caching the results. If I run the individual Powershell commands outside of the script, the correct output is given. So I know the problem has something to do with processing inside the script, but I cannot figure out what that problem is.
I really appreciate your help on this as well as any suggestions you might have on how to improve what I have so far. Ultimately, I am going to write the script so that it can uninstall specific UWP packages based on what the user wants. Thank you.