In case somebody else stumbled over this post, here is a working solution (obviously you want to ideally put everything in a try/catch).
# store your AppToken here
$AppToken = "myAppToken"
# get all schedules
$schedules = Get-PSUSchedule -ComputerName myServer -AppToken $AppToken
# parse them and take the right one you'd like to modify
foreach ($schedule in $schedules)
{
if ($schedule.Name -eq "The name of the schedule I want to modify")
{
# Set the schedule to pause
$schedule.Paused = $false
# Convert the schedule to Json
$scheduleJson = $schedule | ConvertTo-Json
# Finally update the schedule
Invoke-RestMethod "http://myServer:5000/api/v1/Schedule/$($schedule.id)" -METHOD Put -Body $scheduleJson -Headers @{
"Authorization" = "Bearer $AppToken"
"Content-Type" = "application/json"
}
}
}
@adam It might be helpful to have a Set-PSUSchedule cmdlet as well to make everything easier I think. But obviously doing it via REST API works as well… So the suggestion is just to make it a bit more neat and easy to use.