| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Resumes a previously-paused schedule. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | This function resumes a scheduled task that was previously paused. |
| | | 6 | | .PARAMETER Server |
| | | 7 | | The Kestrun host object that manages the schedule. |
| | | 8 | | .PARAMETER Name |
| | | 9 | | The name of the schedule to resume. |
| | | 10 | | .EXAMPLE |
| | | 11 | | Resume-KrSchedule -Name 'ps-inline' |
| | | 12 | | Resumes the schedule named 'ps-inline'. |
| | | 13 | | .OUTPUTS |
| | | 14 | | Returns the Kestrun host object after resuming the schedule. |
| | | 15 | | .NOTES |
| | | 16 | | This function is part of the Kestrun scheduling module. |
| | | 17 | | #> |
| | | 18 | | function Resume-KrSchedule { |
| | | 19 | | [KestrunRuntimeApi('Everywhere')] |
| | | 20 | | [CmdletBinding()] |
| | | 21 | | [OutputType([Kestrun.Hosting.KestrunHost])] |
| | | 22 | | param( |
| | | 23 | | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] |
| | | 24 | | [Kestrun.Hosting.KestrunHost]$Server, |
| | | 25 | | [Parameter(Mandatory = $true)] |
| | | 26 | | [string]$Name |
| | | 27 | | ) |
| | | 28 | | begin { |
| | | 29 | | # Ensure the server instance is resolved |
| | 0 | 30 | | $Server = Resolve-KestrunServer -Server $Server |
| | | 31 | | } |
| | | 32 | | process { |
| | 0 | 33 | | if (-not $Server.Scheduler) { |
| | 0 | 34 | | throw 'SchedulerService is not enabled.' |
| | | 35 | | } |
| | | 36 | | |
| | 0 | 37 | | if ($Server.Scheduler.Resume($Name)) { |
| | 0 | 38 | | Write-Information "▶️ schedule '$Name' resumed." |
| | | 39 | | } else { |
| | 0 | 40 | | Write-Warning "No schedule named '$Name' found." |
| | | 41 | | } |
| | 0 | 42 | | return $Server |
| | | 43 | | } |
| | | 44 | | } |
| | | 45 | | |