fix: use native scheduled task cmdlets and improve error diagnostics
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
param([string]$InstallDirectory = "$env:ProgramFiles\NetBox Windows Agent")
|
||||
$ErrorActionPreference = 'Stop'
|
||||
schtasks.exe /Delete /TN 'NetBox Windows Agent' /F 2>$null
|
||||
Unregister-ScheduledTask -TaskName 'NetBox Windows Agent' -Confirm:$false -ErrorAction SilentlyContinue
|
||||
if (Test-Path -LiteralPath $InstallDirectory) {
|
||||
$resolved = (Resolve-Path -LiteralPath $InstallDirectory).Path
|
||||
$programFiles = (Resolve-Path -LiteralPath $env:ProgramFiles).Path
|
||||
if (-not $resolved.StartsWith($programFiles + '\', [StringComparison]::OrdinalIgnoreCase)) { throw "Unsicheres Ziel: $resolved" }
|
||||
Remove-Item -LiteralPath $resolved -Recurse -Force
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user