Documentation Index

Fetch the complete documentation index at: https://support.controlup.com/llms.txt

Use this file to discover all available pages before exploring further.

PowerShell Cmdlets for Trigger Schedules

Prev Next

From ControlUp version 9.0.5 and higher, you can run the following PowerShell cmdlets to configure trigger schedules on a machine with a ControlUp Monitor installed:

Add-CUTriggerSchedule

Adds a new schedule to the schedule repository. Doesn't add a schedule to a trigger.

Syntax 

Add-CUTriggerSchedule [-Name] <string> [-WeekDays] <DayHours[]>  

Add one day with selected hours trigger schedule example:

$newDayHours = New-Object ControlUp.PowerShell.Common.Contract.Triggers.Schedules.Data.DayHours
$newDayHours.Day = "Wednesday"
$newDayHours.SelectedHours = @("Nine","Ten", "Eleven") 

Add-CUTriggerSchedule -Name "My New Schedule" -WeekDays $newDayHours

Add two days with different selected hours trigger schedule example:

$sundayHours = New-Object ControlUp.PowerShell.Common.Contract.Triggers.Schedules.Data.DayHours
$mondayHours = New-Object ControlUp.PowerShell.Common.Contract.Triggers.Schedules.Data.DayHours

$sundayHours.Day = [System.DayOfWeek]::Sunday
$sundayHours.SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Nine -bor [ControlUp.Common.Enums.IncidentScheduleHour]::Ten -bor [ControlUp.Common.Enums.IncidentScheduleHour]::Eleven

$mondayHours.Day = [System.DayOfWeek]::Monday
$mondayHours.SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Fifteen -bor [ControlUp.Common.Enums.IncidentScheduleHour]::Sixteen -bor [ControlUp.Common.Enums.IncidentScheduleHour]::Seventeen

$weekDays = @($sundayHours, $mondayHours)

Add-CUTriggerSchedule -Name "MyNewSchedule" -WeekDays $weekDays
ParametersDescriptionRequired
-NameName of the trigger scheduleYes
-WeekDaysConfiguration of the weekdays to schedule the trigger to run.Yes
-DayEach specific day of the week to schedule the trigger to run. You can enter each day only once.No
-SelectedHoursSpecific hours of each day to schedule the trigger to run. If empty, the specific day won't be added to the trigger schedule.No

Update-CUTriggerSchedule

Updates an existing trigger schedule name and/or weekdays settings.

Syntax

Update-CUTriggerSchedule [-ScheduleId] <string> [[-Name] <string>] [[-WeekDays] <DayHours[]>]

Rename trigger schedule + update hours example:

Update-CUTriggerSchedule -ScheduleId $scheduleId -Name "Custom Schedule Renamed" -WeekDays @(
@{ Day = [System.DayOfWeek]::Monday; SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Zero + [ControlUp.Common.Enums.IncidentScheduleHour]::One + [ControlUp.Common.Enums.IncidentScheduleHour]::Two + [ControlUp.Common.Enums.IncidentScheduleHour]::Three + [ControlUp.Common.Enums.IncidentScheduleHour]::Four },
@{ Day = [System.DayOfWeek]::Tuesday; SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Zero + [ControlUp.Common.Enums.IncidentScheduleHour]::One + [ControlUp.Common.Enums.IncidentScheduleHour]::Two + [ControlUp.Common.Enums.IncidentScheduleHour]::Three },
@{ Day = [System.DayOfWeek]::Wednesday; SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Zero + [ControlUp.Common.Enums.IncidentScheduleHour]::One + [ControlUp.Common.Enums.IncidentScheduleHour]::Two },
@{ Day = [System.DayOfWeek]::Thursday; SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Zero + [ControlUp.Common.Enums.IncidentScheduleHour]::One },
@{ Day = [System.DayOfWeek]::Friday; SelectedHours = [ControlUp.Common.Enums.IncidentScheduleHour]::Zero }
)

Update trigger schedule hours to Sunday (hours 9:00-11:00) example:

Get-CUTriggerSchedules | Where-Object { $_.Id -eq "bb064f8e-a347-4ce9-bdbd-4b245ac748f2" } | Format-List

$newDayHours = New-Object ControlUp.PowerShell.Common.Contract.Triggers.Schedules.Data.DayHours
$newDayHours.Day = "Sunday"
$newDayHours.SelectedHours = @("Nine","Ten")

Update-CUTriggerSchedule -ScheduleId bb064f8e-a347-4ce9-bdbd-4b245ac748f2 -WeekDays $newDayHours

Add new day to existing trigger schedule:

Update-CUTriggerSchedule -ScheduleId aeb0b292-f519-401b-9da2-49f001b96184 -WeekDays $weekDays
ParametersDescriptionRequired
-ScheduleIdID of the trigger scheduleYes
-NameName of the trigger scheduleNo
-WeekDaysConfiguration of the weekdays to schedule the trigger to run.No
-DayEach specific day of the week to schedule the trigger to run. You can enter each day only once.No
-SelectedHoursSpecific hours of each day to schedule the trigger to run. If empty, the specific day won't be added to the trigger schedule.No

Add-CUTriggerSchedule and Update-CUTriggerSchedule Results

Writes single result object to PowerShell with the following properties:

  • Error. In case of failure, the reason will be displayed.
  • Success. In case of success, all schedule data (Id, Name, WeekDays) will be displayed.

Remove-CUTriggerSchedule

Deletes an existing trigger schedule. Note that you can't delete a trigger schedule currently in use.

Syntax

Remove-CUTriggerSchedule
-[ScheduleId] <string>

Example:

Remove-CUTriggerSchedule
-[ScheduleId] "1e233ec2-af9b-4453-bd29-1fb20e29e514"
ParameterDescriptionRequired
-ScheduleIdID of the trigger scheduleYes

Remove-CUTriggerSchedule Results

Writes single result object to PowerShell with the following properties:

  • Error. In case of failure, the reason will be displayed.
  • Success. In case of success, the trigger is removed and the following message will be displayed: "Schedule '<ScheduleName>' - <ScheduleId> was deleted successfully."

Get-CUTriggerSchedules

Lists all built-in and custom schedules configured for triggers in your environment. No parameters are required. Note that built-in schedules don't have a GUID, but a string constant, e.g “All days”, “Weekdays”, etc.

Syntax

Get-CUTriggerSchedules

Get-CUTriggerSchedules Results

Writes multiple result objects to PowerShell with the following properties:

  • Error. In case of failure, the reason will be displayed.
  • Success. In case of success, returns list of all schedules you can configure to use for triggers with the following properties:
PowerShell
-Id <string>
-Name <string>
-WeekDays <DayHours[]> { -Day <DayOfWeek>; -SelectedHours <IncidentScheduleHour> }

Results example:Powershell window displaying Get-CUTriggerSchedules cmdlet output results