Skip to content

Instantly share code, notes, and snippets.

@ak9999
Created September 21, 2019 23:48
Show Gist options
  • Select an option

  • Save ak9999/e68da02d7957bd7db2a2a647f76d50be to your computer and use it in GitHub Desktop.

Select an option

Save ak9999/e68da02d7957bd7db2a2a647f76d50be to your computer and use it in GitHub Desktop.
Uninstall LabTech and ScreenConnect Agents: For those who are having a hard time uninstalling the LabTech Agent from their computer, the first script will remove the LabTech Agent, and the second will remove ScreenConnect aka (ConnectWise Control).
$url = "https://s3.amazonaws.com/assets-cp/assets/Agent_Uninstaller.zip"
$output = "C:\Windows\Temp\Agent_Uninstaller.zip"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
# The below usage of Expand-Archive is only possible with PowerShell 5.0+
# Expand-Archive -LiteralPath C:\Windows\Temp\Agent_Uninstaller.zip -DestinationPath C:\Windows\Temp\LTAgentUninstaller -Force
# Use .NET instead
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
# Now we can expand the archive
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Windows\Temp\Agent_Uninstaller.zip', 'C:\Windows\Temp\LTAgentUninstaller')
Start-Process -FilePath "C:\Windows\Temp\LTAgentUninstaller\Agent_Uninstall.exe"
wmic product where "name like 'ScreenConnect Client%%'" call uninstall /nointeractive
@owner232

Copy link
Copy Markdown

Thank you! Helped so much

@ak9999

ak9999 commented Dec 7, 2021

Copy link
Copy Markdown
Author

Glad to hear it helped someone!

@julian-heidt

Copy link
Copy Markdown

So, I got the script working in my environment, but I was wondering what the AWS link is from. Is it a personal repo or an enterprise one? My main concern is using personal repos in a production environment. Would it be possible to change that from the AWS link to a server share perhaps?

@ak9999

ak9999 commented Dec 10, 2021

Copy link
Copy Markdown
Author

If you have ConnectWise Automate, when you click to download the agent uninstaller, they give you this link. You can access it whenever you want without authentication, so I just used it in my script.

@orgitnized

Copy link
Copy Markdown

To this day it still works. I love you for making it haha - works perfectly!!! Thanks again for making this, @ak9999

@ak9999

ak9999 commented Jun 14, 2022

Copy link
Copy Markdown
Author

To this day it still works. I love you for making it haha - works perfectly!!! Thanks again for making this, @ak9999

Music to my ears. :)

@jftirone

Copy link
Copy Markdown

Awesome, saved me a lot of heartache.

@patthen

patthen commented Sep 22, 2022

Copy link
Copy Markdown

<3 <3 <3

@Eternal-student

Copy link
Copy Markdown

Awesome from me too, thank you v much

@JasonPavlas

Copy link
Copy Markdown

Nice, clean, and simple solution you made!

I could have sworn I saved the uninstall file SOMEWHERE, but NOPE...

Ran your script in powershell ISE, I got a pop-up asking me if I wanted to run the Automate Uninstaller (had the connectwise branding, too) and BOOM.

Thanks, Sir!

@Imburr

Imburr commented Jun 7, 2023

Copy link
Copy Markdown

Will this work on a probe?

@MartinO-95

Copy link
Copy Markdown

Works great! Thanks for this!

@ssi-eenwall

Copy link
Copy Markdown

Brilliant, thank you.

@Slyborg-Network

Copy link
Copy Markdown

Just made an account to let you know it's still helping people to this day, so thanks a lot for that! :)

@danny3n1tech

Copy link
Copy Markdown

Still working!!!

@ak9999

ak9999 commented May 23, 2024

Copy link
Copy Markdown
Author

Very happy to hear this. I am no longer working in the MSP space, but I am happy to hear that this helped so many people.

@sbouillon

Copy link
Copy Markdown

Thank you! We'll let you know when it's no longer working so you can get a small taste of the MSP space again :)

@EmpireConsultants

Copy link
Copy Markdown

If you get the following error with System.Net.Webclient:
The request was aborted could not create ssl/tls secure channel

Just add this to the top of the script
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

@FarVision2

Copy link
Copy Markdown

Still works :)
MSPs still exiting clients without proper cleanup.

@ZSchwarttzy

Copy link
Copy Markdown

Might be slower, but that that "Agent_Uninstaller.exe" is basically just a zip file. Use 7-zip, or whatever, to open the file and pull out both that Uninstall.exe and the Uninstall.exe.config files. Put those in the same location and run the Uninstall.exe. Takes a moment but should still do the trick.

labtech uninstaller

@ScottMonolith

Copy link
Copy Markdown

Went through writing a script to identify the uninstall string in the registry and found that it didn't do squat. This script, however, still delivers in 2025. Thanks!

@mariomurrent-softwaresolutions

Copy link
Copy Markdown

Still works, awesome 👍

@InsanityOnABun

Copy link
Copy Markdown

While the script seems to work fine, I'm leery about how generic and unaffiliated the $url link appears to be with ConnectWise. Is there any official documentation or support that shows this isn't some random file that someone could swap out at any time for a malicious version?

@ak9999

ak9999 commented Apr 29, 2026

Copy link
Copy Markdown
Author

@InsanityOnABun I wrote this a very long time ago and stopped working for MSPs not too long after I wrote it, but I got this link from opening (at the time) ConnectWise Automate and looking for the Agent Uninstaller there. If there is documentation, it isn't prominent. As far as I know, assets-cp is ConnectWise's AWS S3 bucket.

@realchrisolin

realchrisolin commented May 12, 2026

Copy link
Copy Markdown

While the script seems to work fine, I'm leery about how generic and unaffiliated the $url link appears to be with ConnectWise. Is there any official documentation or support that shows this isn't some random file that someone could swap out at any time for a malicious version?

Does a powershell command that doesn't connect to any web resources work instead? Dunno about any "official documentation or support", but it has the benefit of working.

( Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -like 'ConnectWise Automate*'} ) | ForEach-Object {
& msiexec /x $_.IdentifyingNumber /quiet /qn /norestart
}

@ak9999

ak9999 commented May 12, 2026

Copy link
Copy Markdown
Author

At the time that I wrote these scripts, I was trying to clean up old agents that would not uninstall, did not show up under Win32_Product queries, didn’t have clean registry entries for the agents. And I had to get it done across thousands of endpoints, without downtime.

If you are a subscriber to ConnectWise Automate, go to the link in your Automate interface for the agent uninstaller and compare it to the one in the script above, that should resolve your doubts. I know it’s frustrating to trust a “random URL”, but that’s how you can verify it. Again, I haven’t used ConnectWise Automate in years, I just left this up here to help others.

@realchrisolin Your script is the “happy path” where everything is clean. I didn’t have that scenario. The Agent Uninstaller works no matter if whoever installed the agent made it so it would only uninstall if the server told the agent to uninstall itself, or if the agent got corrupted, or if the registry is broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment