I have a request from an end user that is looking to have an option in their Software Center to clear their cache and cookies. I drummed up a pretty basic Deploy-Application. I have the pre-installation task creating a registry key (for detection purposes) and also closing out Chrome. In the installation section, I tell it to do the following:
Thanks for the response. I just reviewed all the PSADT variables that are available and if $envUserProfile is not working (possibly due to the system account), which variable do you think I should possibly try in that case? I saw one that would affect all profile users, but I would prefer to try and keep this solely for the current signed in user.
Side note, I am checking a colleague of mine’s script for a Teams cache removal and he is using the same variable as I am. His script works fine with no issues and does not prompt for UAC.
As That-Annoying-Guy wrote, the problem could be that in your case the $envUserProfile variable points to the system profile, not the profile of the user sitting in front of the computer. You may be able to solve the problem by running the script in the user’s context, not the local system context. You must configure this in the deployment’s “User Experience” settings within the Config Manager application. Note that you will then no longer be able to use the PSAppDeployment toolkit as, to my knowledge, Deploy-Application.exe needs admin privileges to run. You could instead run a simple command line batch file that deletes the folders and creates the detection registry key. In this case, this registry key must be in HKCU, not in HKLM.
Thanks for the response. Took the last part of your advice and made the Set-RegistryKey under the HKCU and not HKLM.
I ended up make a duplicate of my co-worker’s script and then removed/inserted what was needed. I wasn’t going to spend the time tearing it apart to see if there was a typo somewhere, but now the issue is resolved and the script works!