Skip to content

Instantly share code, notes, and snippets.

@daveselias
Created June 2, 2016 01:43
Show Gist options
  • Save daveselias/68a2bc02e78a6a422d2408c5ee3b6e29 to your computer and use it in GitHub Desktop.
Save daveselias/68a2bc02e78a6a422d2408c5ee3b6e29 to your computer and use it in GitHub Desktop.
start all LANDesk 9.6sp2 scheduled tasks
$core = "MyCoreServerName"
$ldmS = New-WebServiceProxy -uri http://$core/MBSDKService/MsgSDK.asmx?WSDL -UseDefaultCredential
$TASKS = $LDMS.ListSWDTasks()
$NoPush = $TASKS.ScheduledTasks | Where-Object {($_.DeliveryMethodName -notlike '*push*') -and ($_.Status -like "Available For Download")} | Sort-Object TaskID
$T = $NoPush.count
$N=0
ForEach($Task in $NoPush){
$N++
$Started = $LDMS.StartTaskNow("$($Task.TaskID)","all")
IF($Started -eq $true){
Write-Host "Successfully started Task ($N of $T) $($task.TaskName)"
}ELSEIF($Started -eq $false){
Write-Warning -Message "Failed to start Task ($N of $T) $($task.TaskName)"
}
IF($N -like '*0'){
Write-Host "----Waiting 5 minutes for the previous 10 tasks to complete----" -ForegroundColor Cyan
Start-Sleep -Seconds 300
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment