Task Scheduler: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „== Create a Task in Windows Task Scheduler == Because of an Splunk Universal Forwarder issue, we had to create a task to check if the subprocess are running af…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
== Create a Task in Windows Task Scheduler == | == Create a Task in Windows Task Scheduler == | ||
− | Because of an Splunk Universal Forwarder issue, we had to create a task to check if the subprocess are running after a reboot. | + | Because of an Splunk Universal Forwarder issue, we had to create a task to check if the subprocess are running after a reboot. If the subprocess is not running, restart the service. |
<source lang="powershell"> | <source lang="powershell"> | ||
$TaskName = "Splunk Workaround" | $TaskName = "Splunk Workaround" |
Version vom 13. September 2021, 11:59 Uhr
Create a Task in Windows Task Scheduler
Because of an Splunk Universal Forwarder issue, we had to create a task to check if the subprocess are running after a reboot. If the subprocess is not running, restart the service.
$TaskName = "Splunk Workaround" $TaskDescription = "Restart Splunk Service if splunk-wineventlog.exe is not running." $TaskAction = New-ScheduledTaskAction -Execute "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Argument '-NoProfile -WindowStyle Hidden -command "& If (!(Get-Process splunk-winevtlog)) {Restart-Service SplunkForwarder}"' $TaskTriggers = (New-ScheduledTaskTrigger -AtStartup -RandomDelay (New-TimeSpan -Minutes 5)), (New-ScheduledTaskTrigger -Daily -At '5:00 AM') $TaskSettings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) Register-ScheduledTask -TaskName $TaskName -Description $TaskDescription -Action $TaskAction -Trigger $TaskTriggers -Settings $TaskSettings -User "System" -RunLevel Highest -Force