Start-ScheduledScript.ps1
19 Sep 2025Description
Purpose
Starts a scheduled task by its name.
Detailed Description
The Start-ScheduledScript function starts a scheduled task by its name. It checks if the task exists and then starts it.
Usage
Example 1
Start-ScheduledScript -TaskName "MyTask"
This example starts the scheduled task named “MyTask”.
Notes
No additional notes.
Script
<#
.SYNOPSIS
Starts a scheduled task by its name.
.DESCRIPTION
The Start-ScheduledScript function starts a scheduled task by its name. It checks if the task exists and then starts it.
.PARAMETER TaskName
The name of the scheduled task to start.
.EXAMPLE
Start-ScheduledScript -TaskName "MyTask"
This example starts the scheduled task named "MyTask".
#>
function Start-ScheduledScript {
[CmdletBinding(SupportsShouldProcess = $true)]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[string]
$TaskName
)
if ($PSCmdlet.ShouldProcess("$TaskName", "Start scheduled task")) {
try {
if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) {
Start-ScheduledTask -TaskName $TaskName
}
else {
Write-Error "No scheduled task found with the name $TaskName"
}
}
catch {
Write-Error "Failed to start scheduled task: $_"
}
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.