-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDRMM-WINSCR-DNSFilterUninstall.ps1
More file actions
48 lines (41 loc) · 1.71 KB
/
Copy pathDRMM-WINSCR-DNSFilterUninstall.ps1
File metadata and controls
48 lines (41 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
.SYNOPSIS
Using Datto RMM, uninstall the DNSFilter Agent from a Windows device.
Based off https://help.dnsfilter.com/hc/en-us/community/posts/33824571207955-Migrating-Roaming-Clients-between-organizations-in-DNSFilter
Written by Lee Mackie - 5G Networks
.NOTES
Type: Script
Version 1.1 - Updated uninstallation commands
#>
function Uninstall-App {
Write-Output "Uninstalling $($args[0])"
foreach($obj in Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall") {
$dname = $obj.GetValue("DisplayName")
if ($dname -contains $args[0]) {
$uninstString = $obj.GetValue("UninstallString")
foreach ($line in $uninstString) {
$found = $line -match '(\{.+\}).*'
If ($found) {
$appid = $matches[1]
Write-Output $appid
Write-Host "Found $($args[0]) - initiating uninstallation command"
start-process "msiexec.exe" -arg "/X $appid /qb" -Wait
}
}
}
}
}
# Remove DNSFilter
Write-Host "Attempting uninstallation..."
Uninstall-App "DNSFilter Agent"
Uninstall-App "DNS Agent"
Start-Sleep 10
# Remove registry keys
Write-Host "Removing Registry Keys..."
Remove-Item -Path "HKLM:\Software\DNSFilter" -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\Software\DNSAgent" -Recurse -ErrorAction SilentlyContinue
# Remove file paths
Write-Host "Removing remaining files and folders"
Remove-Item "C:\Program Files\DNSFilter Agent\" -Recurse -ErrorAction SilentlyContinue
Remove-Item "C:\Program Files\DNS Agent\" -Recurse -ErrorAction SilentlyContinue
Write-Host "---- Script completed, DNSFilter software should have been removed."