I found below code to launch a scheduled task in Windows' 10 Task Scheduler. It spawns a PowerShell Window while the task is executing, and the task runs as expected. I expected to see the message "Waiting on scheduled task ..." displayed in the PowerShell window while the task was running. However, the message isn't displayed. How can I achieve that?
Start-ScheduledTask -TaskName "\FOLDER\TASK_NAME";
while ((Get-ScheduledTask -TaskName 'TASK_NAME').State -ne 'Ready') {
Write-Verbose -Message "Waiting on scheduled task..."
}
Thank you.
-Verboseat the end ofWrite-Verbosecommand