mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
28 lines
729 B
PowerShell
28 lines
729 B
PowerShell
function Remove-ItemSecure()
|
|
{
|
|
param(
|
|
[string]$Path,
|
|
[switch]$Recurse,
|
|
[switch]$Force
|
|
)
|
|
|
|
if ((Test-Path $Path) -eq $FALSE) {
|
|
return $FALSE;
|
|
}
|
|
|
|
try {
|
|
if ($Recurse -And $Force) {
|
|
Remove-Item -Path $Path -Recurse -Force;
|
|
} elseif ($Recurse -And -Not $Force) {
|
|
Remove-Item -Path $Path -Recurse;
|
|
} elseif (-Not $Recurse -And $Force) {
|
|
Remove-Item -Path $Path -Force;
|
|
} else {
|
|
Remove-Item -Path $Path;
|
|
}
|
|
return $TRUE;
|
|
} catch {
|
|
Write-Host ([string]::Format('Failed to remove items from path "{0}": {1}', $Path, $_.Exception)) -ForegroundColor Red;
|
|
}
|
|
return $FALSE;
|
|
}
|