remove-item "C:\Program Files (x86)\Genetec AutoVu 6.*\MobileClient\PermitList\*.*" remove-item "C:\Program Files (x86)\Genetec AutoVu 6.*\MobileClient\HotList\*.*" remove-item "C:\Program Files\Genetec AutoVu 6.*\MobileClient\PermitList\*.*" remove-item "C:\Program Files\Genetec AutoVu 6.*\MobileClient\HotList\*.*" Function UpdateUtilityTask() { # find the Utility Script task $taskName = "Daily Genetec Clear" $task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue # schedule a new task if none found if ($null -eq $task) { if ($Debug) { Write-Output "Adding daily Genetec Clear Script task" } $A = New-ScheduledTaskAction -Execute "Powershell.exe" -Argument "-File `"C:\scripts\ClearGenetecFiles.ps1`"" $T = New-ScheduledTaskTrigger -AtStartup $P = "NT AUTHORITY\SYSTEM" $S = New-ScheduledTaskSettingsSet $task = Register-ScheduledTask -TaskName $taskName -Action $A -Trigger $T -User $P -Settings $S -Description "Genetec Clear Script" } elseif ($Debug) { Write-Output "Daily Genetec Clear Script task exists" } } UpdateUtilityTask