mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
23 lines
750 B
PowerShell
23 lines
750 B
PowerShell
function Uninstall-IcingaAgent()
|
|
{
|
|
$IcingaData = Get-IcingaAgentInstallation;
|
|
|
|
if ($IcingaData.Installed -eq $FALSE) {
|
|
Write-Host 'Unable to uninstall the Icinga Agent. The Agent is not installed';
|
|
return;
|
|
}
|
|
|
|
Write-Host 'Removing current installed Icinga Agent';
|
|
|
|
Stop-IcingaService 'icinga2';
|
|
|
|
$Uninstaller = Start-IcingaProcess -Executable 'MsiExec.exe' -Arguments ([string]::Format('{0} /q', $IcingaData.Uninstaller)) -FlushNewLine;
|
|
|
|
if ($Uninstaller.ExitCode -ne 0) {
|
|
Write-Host ([string]::Format('Failed to remove Icinga 2 Agent: {0}{1}', $Uninstaller.Message, $Uninstaller.Error));
|
|
return $FALSE;
|
|
}
|
|
|
|
Write-Host 'Icinga Agent was successfully removed';
|
|
return $TRUE;
|
|
}
|