-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin-agent-remover.ps1
36 lines (36 loc) · 957 Bytes
/
win-agent-remover.ps1
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
###### HOW TO USE ######
# As administrator run the PowerShell script
# powershell .\win-agent-remover.ps1
#
#
function Remove-Agent {
$REMOVE_ANSWER = Read-Host -Prompt "[!] Do you wish to remove the Agent? (Y/N)"
$REMOVE_ANSWER = $REMOVE_ANSWER.ToUpper()
if ($REMOVE_ANSWER -eq 'Y') {
Write-Host "[*] Starting Agent Removal..."
try
{
$WAZ_AGENT = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Wazuh Agent"}
$WAZ_AGENT.Uninstall()
if(Test-path 'C:\Program Files (x86)\ossec-agent') {
Remove-Item 'C:\Program Files (x86)\ossec-agent\' -Recurse
}
Write-Host "[*] Agent successfully removed!" -ForegroundColor Green
Exit 0
}
catch
{
Write-Host "[*] Error with: Removing Agent"
Write-Host "[*] The Agent failed to be removed." -ForegroundColor Red
Exit 1
}
}
else {
Write-Host "[*] The Agent was not removed."
}
}
#
#
if(Test-path 'C:\Program Files (x86)\ossec-agent') {
Remove-Agent
}