Skip to content

Instantly share code, notes, and snippets.

@DarkAllien
Last active July 4, 2018 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkAllien/cb2d3aff2ed2e68a29ffe0cfd5647029 to your computer and use it in GitHub Desktop.
Save DarkAllien/cb2d3aff2ed2e68a29ffe0cfd5647029 to your computer and use it in GitHub Desktop.
$time = Get-Date
"$time - CI.SQL.Servers.AppEval - Evaluation - Creating Application Evaluation Schedulled Task" | out-file "$env:windir\Logs\CB.SQL.Servers.Updates.log" -Append
Unregister-ScheduledTask -TaskName SCCMAppEval -Confirm:$False -ErrorAction Ignore | Out-Null
$taskname = "SCCMAppEval"
$taskdescription = "SCCMAppEval"
$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument "-Noprofile -Windowstyle Hidden -command & {Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000121}'}"
$trigger = New-ScheduledTaskTrigger -AtStartup -RandomDelay (New-TimeSpan -minutes 10)
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1)
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $taskname -Description $taskdescription -Settings $settings -User "System" -RunLevel Highest | Out-Null
return $true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment