Since people are working from home now, and not on the network, I have been trying to write a script to uninstall programs over the internet. I have done this before for laptops on the network, and set it as a login script for a user with admin privs. Then we just login to the laptop with that user, and the script launches and does the uninstall.

Now, I can use our MDM to push out the script, and then click to run it, but it will ask for admin user and password. It works when I put in the credentials, but I can’t do that for every laptop. Is there some way to embed the admin username and password into the script so that it runs quietly and uninstalls the program?

Here is the script. I have seen variations of the script that uses psiexec but that is not installed on the laptop. There’s also one that uses wmic, but I don’t know how to use that, and I don’t think it works locally on the PC.

@ECHO OFF
REM — Uninstall Classroom Windows
MsiExec /X{10356733-7D4D-4007-9427-37BD1CB7D646} /quiet
REM — Uninstall NWEA Secure Testing Browser
MsiExec /I{8d32f6ed-a95e-44e2-af74-a66fd1f260b8} /quiet
REM — Uninstall Teams Machine-Wide Installer
MsiExec /I{731F6BAA-A986-45A4-8936-7C3AAAAA760B} /quiet

6 Spice ups

You can do that in powershell: Get-Credential (Microsoft.PowerShell.Security) - PowerShell | Microsoft Learn

I don’t think I can run a powershell script remotely. Wouldn’t I have to install the module that allows this manually?