What It Does
This script changes nothing until you set DryRun=false and Approve=remove-remote-access-tools. The dry run lists everything it would remove. It refuses to make more than 25 changes in one run unless you raise MaxChanges.
It looks for about 25 remote-access tools, using its own detection list, and targets tools that do not match AllowedTools. Installed tools are removed with the silent uninstaller from the installed-programs list, and then their leftover Windows services and program folders are deleted. With SearchPortable on, it searches Downloads, Desktop, Documents and AppData for matching portable copies, stops a running copy when permitted, then deletes the file. A running portable copy is only stopped when nobody is signed in or Force is true. Before a service is deleted its registry key is backed up with reg export.
AllowedTools is required: the tools to keep, by the names get-remote-access-tools reports, with wildcards allowed. An empty list is refused, because it would remove your own remote-support tool too, unless you set RemoveAll to true. If a targeted tool is running this script, the run refuses before changing anything unless Force is true. Forcing that removal can cut the run short.
It does not block a removed tool from being run or downloaded again. Do that in your endpoint-security tool. It warns about and skips a tool with no known silent uninstall method. If that leaves no tools to remove, the run ends in error.
Before You Run It
- Run get-remote-access-tools first and write down the exact names to put in AllowedTools.
- Include your own remote-support tool in AllowedTools if you need to keep it. An empty list is refused unless RemoveAll is on.
- Run it once as a dry run and read the list before you approve it.
- Tell the client first. Staff who use a removed tool will notice.
Type and Risk
- Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
- Risk: High. It is a dry run unless you set both DryRun=false and Approve=remove-remote-access-tools, and it stops before making more than 25 changes in one run unless you raise MaxChanges. Run it once as a dry run and read the list first.
- What it changes: Uninstalls remote-access tools not on the allow-list, deletes their leftover services and program folders, and deletes portable copies in user folders.
- Restart: It never restarts the machine itself. When a restart is needed to finish, the answer says so.
- Typical run: 1 to 10 minutes.
- Example answer: "Removed 2 remote-access tools: AnyDesk, TeamViewer; kept: Splashtop"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- AllowedTools: Tool names to KEEP, separated by commas, semicolons or new lines. Wildcards * and ? work. Required unless RemoveAll is true.
- RemoveAll: true to remove every remote-access tool, with an empty AllowedTools. Default false.
- SearchPortable: true (default) to also find and delete portable copies in user folders.
- Force: true to stop a running portable copy while somebody is signed in, and to remove a tool that is running this script. Default false.
- TimeoutSeconds: How long to wait for each uninstaller. Whole number, 30 to 7200. Default 600.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.