Private/Get-specScheduledTask.ps1

function Get-specScheduledTask {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [string]$TaskName,

        [Parameter(Mandatory)]
        [string]$TaskPath
    )

    try {
        return Get-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -ErrorAction Stop
    } catch {
        throw "Cannot find task '$TaskName' in path '$TaskPath'. $_"
    }
}