I’m having several issues trying to force uninstall applications by GUID that bypasses UAC and skips the “Are you sure you want to uninstall” prompts. I’m newer to this so I’m trying to figure this out on my own but no luck.
GPO configured to have a PowerShell script for Computer Configuration > Windows Settings > Scripts for Startup pointing to network share location of script.
Computer Config > Administrative Template > Windows Components > Windows Powershell “Turn on Script Execution” enabled to allow all scripts.
When pushed out the user device hangs and doesn’t uninstall anything. Is there a GPO setting I’m missing or is my script completely wrong? Or maybe there is a better method of doing this through GPO?
It could be something silly like the GUID not having double quotes around it.
It has quotes around it when you define it in your array, but that tells PowerShell that it’s a string. When you later cast the variable inside of double quotes to satisfy ArgumentList it’s literally printing this:
I removed the Set-ExecutionPolicy line because it doesn’t do anything in the context of your task.
The method I shared is using something called a Format Operator (the -f) and it’s handy for allowing you to cast strings with some pretty controlled formatting:
'/x "{0}" /qn' -f $guid
# produces output with quotes around the GUID
/x "{3C957E7F-B142-4815-9AC1-484FD15F36A9}" /qn