I'm trying to run an antivirus scan via PowerShell as a background process.
My code:
$arg1 = "/c"
$arg2 = "/ScanAllDrives"
$logFile = "/LOGFILE='C:\Users\user\AppData\Local\Symantec\Symantec Endpoint Protection\Logs\test.log'"
Start-Job -ScriptBlock {"C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.7004.6500.105\Bin\DoScan.exe"} -ArgumentList "$arg1 $arg2 $logFile
The job runs for a second then stops. Get-Job
shows it has completed, but it has not given the runtime and lack of log file.
It works fine when I run it from the PowerShell console as follows:
& "C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.7004.6500.105\Bin\DoScan.exe" /c /ScanAllDrives
Any idea why this won't run in the background? I've tried adding the args directly into the scriptblock but it doesn't seem to like that at all. I'm not finding it easy to see why it completes as the background job doesn't produce any output.