mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Adds support to fully uninstall the Icinga 2 agent including ProgramData
Fixes #67
This commit is contained in:
parent
84975a4759
commit
d983f6f767
1 changed files with 13 additions and 1 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
function Uninstall-IcingaAgent()
|
function Uninstall-IcingaAgent()
|
||||||
{
|
{
|
||||||
|
param (
|
||||||
|
[switch]$RemoveDataFolder = $FALSE
|
||||||
|
);
|
||||||
|
|
||||||
$IcingaData = Get-IcingaAgentInstallation;
|
$IcingaData = Get-IcingaAgentInstallation;
|
||||||
|
|
||||||
if ($IcingaData.Installed -eq $FALSE) {
|
if ($IcingaData.Installed -eq $FALSE) {
|
||||||
|
|
@ -18,6 +22,14 @@ function Uninstall-IcingaAgent()
|
||||||
return $FALSE;
|
return $FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($RemoveDataFolder) {
|
||||||
|
[string]$IcingaProgramData = Join-Path -Path $Env:ProgramData -ChildPath 'icinga2';
|
||||||
|
Write-IcingaConsoleNotice -Message 'Removing Icinga 2 directoy from ProgramData: "{0}"' -Objects $IcingaProgramData;
|
||||||
|
if ((Remove-ItemSecure -Path $IcingaProgramData -Recurse -Force) -eq $FALSE) {
|
||||||
|
return $FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Write-IcingaConsoleNotice 'Icinga Agent was successfully removed';
|
Write-IcingaConsoleNotice 'Icinga Agent was successfully removed';
|
||||||
return $TRUE;
|
return $TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue