Hey everyone! I'm tackling an issue where I come across laptops with random software like Roblox or Steam installed, and I need to remove them without diving into each machine manually. I attempted to write a script using PowerShell that first identifies the blacklisted apps, but I'm running into trouble with the conditions and uninstalling the apps automatically. I list my blacklisted software in an array, and use Get-WmiObject to find installed programs, but I keep getting issues with empty DisplayNames and not being able to correctly identify the apps. I'm also looking to automate the uninstallation process given a name. Anyone got suggestions or better methods? Thanks!
5 Answers
Instead of just uninstalling, why not address the problem at its root? Consider implementing AppLocker or WDAC to prevent unwanted installs in the first place. If you still want to automate uninstalls, make sure to get the silent uninstall strings of the apps since many won’t use the standard uninstall methods. Remember, user-installed UWP apps usually won't show up unless you run your scripts as an administrator, or specify that you want to check all users.
Totally feel you on the frustrations of uninstalling apps! Steam can be particularly tricky because it doesn’t have a straightforward silent uninstall option. In my experience, if I find Steam is installed, I check where the games are stored since users often put them on external drives. If they’re on an external drive, that could complicate the uninstall process. You might need to talk to the user if you can’t access the app directly, or try removing registry entries which also can be hit or miss!
You should definitely avoid using Get-WmiObject for this. It's known to have some quirks. Instead, try using the newer Get-Package command in PowerShell. You can simply run something like `Get-Package *AppName* | Uninstall-Package` for MSI apps. This could streamline your uninstall process significantly! Also, be cautious because some apps, especially like Steam, can be a real pain to uninstall properly since they don’t always follow standard uninstall processes. You might need to manually deal with some leftovers afterward!
For sure! Managing uninstalls, especially with certain apps, is tricky. I've ended up doing a lot of manual clean-up myself.
For your specific issue with comparing DisplayNames to your blacklist, you've got a small mistake there. Instead of using -like with an array, consider using -in to check if the DisplayName exists within your blacklist. This should solve your filtering issue!
Yeah, I’d recommend looping through the blacklist to make the comparisons clearer. It would definitely help streamline your script!
Great catch! I struggled with similar comparisons before and switching to -in made all the difference.
Have you thought about why users are allowed to install these applications in the first place? Once you get the current machines cleaned up, set some strict policies to prevent future installations. It can save you a lot of headaches down the road!

Good point about Get-WmiObject! I had a tough time with it too when I tried to automate similar tasks.