| | 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 |
| 0 | 31 | | if ($null -eq $Server) { |
| 0 | 32 | | throw 'Server is not initialized. Please ensure the server is configured before setting options.' |
| | 33 | | } |
| | 34 | | } |
| | 35 | | process { |
| 0 | 36 | | if (-not $Server.Scheduler) { |
| 0 | 37 | | throw 'SchedulerService is not enabled.' |
| | 38 | | } |
| | 39 | |
|
| 0 | 40 | | if ($Server.Scheduler.Resume($Name)) { |
| 0 | 41 | | Write-Information "▶️ schedule '$Name' resumed." |
| | 42 | | } else { |
| 0 | 43 | | Write-Warning "No schedule named '$Name' found." |
| | 44 | | } |
| 0 | 45 | | return $Server |
| | 46 | | } |
| | 47 | | } |
| | 48 | |
|