Hey Guys trying to get some help with script below. Can’t get script to work. task scheduler is show a last run result (0x1)
$uninstallCommand = “C:\Program Files\Sophos\Sophos Endpoint Agent\SophosUninstaller.exe /S”
$action = New-ScheduledTaskAction -Execute “powershell.exe” -Argument “-NoProfile -ExecutionPolicy Bypass -Command "$uninstallCommand
”"
$trigger = New-ScheduledTaskTrigger -Once -At “2:50PM”
$principal = New-ScheduledTaskPrincipal -UserId “SYSTEM” -LogonType ServiceAccount
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
Register-ScheduledTask -TaskName “Silent Uninstall Sophos” -Action $action -Trigger $trigger -Principal $principal -Settings $settings
Write-Output “Scheduled task ‘Silent Uninstall Sophos’ created successfully.”