Skip to content
Snippets Groups Projects
Commit 86c38f1f authored by Andreas Lindemark's avatar Andreas Lindemark
Browse files

Updated with more cleanup, and made it specifically for Zabbix agents

parent b3a6d21e
No related branches found
No related tags found
No related merge requests found
<#====================================================
Remove specified Chocolatey packages and clean up
====================================================#>
<#=======================================================
Remove Zabbix Agent and Zabbix Agent 2 and clean up
=======================================================#>
# Start the Script
Write-Host "Starting script execution..."
......@@ -92,6 +92,19 @@ function Remove-ZabbixAgentRemnants {
}
}
# Function to search for Zabbix files in specified paths
function Search-ZabbixFiles {
param (
[string]$searchPath,
[string]$searchPattern
)
Write-Output "Searching for Zabbix files in $searchPath..."
$files = Get-ChildItem -Path $searchPath -Recurse -Filter $searchPattern -ErrorAction SilentlyContinue
foreach ($file in $files) {
Write-Output "Found file: $($file.FullName)"
}
}
# Remove Zabbix Agent
Write-Output "Stop Zabbix Agent service and uninstall."
Stop-ServiceIfExists -ServiceName "Zabbix Agent"
......@@ -104,6 +117,13 @@ Stop-ServiceIfExists -ServiceName "Zabbix Agent 2"
Uninstall-ChocoPackageIfExists -PackageName "zabbix-agent2"
Remove-ZabbixAgentRemnants -AgentName "Zabbix Agent 2" -InstallPath "C:\Program Files\Zabbix Agent 2" -ServiceName "Zabbix Agent 2"
# Search for Zabbix files in specified paths
Search-ZabbixFiles -searchPath "C:\ProgramData\chocolatey" -searchPattern "*zabbix*"
Search-ZabbixFiles -searchPath "C:\ProgramData\ChocolateyHttpCache" -searchPattern "*zabbix*"
# Inform that a reboot should be done
Write-Host "A reboot should be done before reinstalling any of the Zabbix agents."
# Stop Transcript
Write-Host "Stopping transcript..."
Stop-Transcript
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment