Scripts/ScheduledTask.ps1
$TaskName = "SystemCheck" $Task = Get-ScheduledTask $TaskName -ea 0 $Execute = "pwsh.exe" $Argument = "-ex bypass -file D:\Scripts\SystemCheck.ps1" $User = "HMP\svc_SystemCheck" $TriggerParams = @{ Daily = $true At = "7:55AM" } if (-not($Task)) { $TaskAction = New-ScheduledTaskAction -Execute $Execute -Argument $Argument $TaskTrigger = New-ScheduledTaskTrigger @TriggerParams Register-ScheduledTask -Action $TaskAction -Trigger $TaskTrigger -TaskName $TaskName -User $User -RunLevel Highest -TaskPath "\Hydromaster\" } |