Why is my Zoom removal script failing to execute?

0
1
Asked By TechieTurtle42 On

I've been trying to create a PowerShell script to uninstall Zoom from multiple user accounts on my machine. Here's the script I'm using:

```powershell
$users = Get-ChildItem C:Users | Select-Object -ExpandProperty Name
foreach ($user in $users) {
$zoomPath = "C:Users$userAppDataRoamingZoomuninstallInstaller.exe"
if (Test-Path $zoomPath) {
Start-Process -FilePath $zoomPath -ArgumentList "/uninstall" -Wait
}
}
```

I'm planning to push this through group policy, but I've tested it by deploying through MECM on my own device and it failed. The file path appears correct, so I'm wondering if it's an issue with the script or with MECM. Any advice?

5 Answers

Answered By ScriptingGuru On

Looks like you might be missing a double backslash in your path here: "C:\Users$user\". Add that and give it another shot. Also, consider using winget to make the whole uninstallation process simpler.

Answered By ScriptSavvy_101 On

I noticed a potential issue in your script. You seem to be missing a backslash between "C:\Users" and "$user\AppData....". Fix that and see if it works. Also, could you provide more context?

How are you executing the script with MECM and under which user account? Are there any error messages popping up? What happens when you run the script manually? It might also help to add some logging to your script to pinpoint where it might be failing.

Answered By CodeNinja88 On

You didn’t mention what exactly fails. Can you share the error message? Also, check what happens when you run it manually to see if it behaves differently.

TechieTurtle42 -

I’ll check that! I didn’t get an error message when I tried it manually, but maybe I missed something. Thanks for the tip!

Answered By PowerShellPro93 On

I don’t think this will work as you expect. The script runs in your context, meaning you're trying to uninstall Zoom from your profile, not from others’. You should just reference $env:Appdata once per user and look for the uninstaller before trying to run it. You’ll need to ensure the script runs in each user's session, possibly at logon.

Answered By OldScriptFinder On

I found a useful script that removes Zoom in a more structured way:

```powershell
[System.Collections.ArrayList]$UserArray = (Get-ChildItem C:Users).Name
$UserArray.Remove('Public')

New-PSDrive HKU Registry HKEY_USERS
Foreach($obj in $UserArray){
$Parent = "$env:SystemDriveusers$objAppdataRoaming"
$Path = Test-Path -Path (Join-Path $Parent 'zoomuninstall')
if($Path){
# Logic to remove Zoom
}
}
Remove-PSDrive HKU
```

This script checks each user's app data and removes Zoom if it finds the uninstaller.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.