I have the following simple PowerShell script:
foo "Hello World!"
Start-Sleep 5
function foo($message) {
write-host $message
}
This works correctly when I run from the ISE. However, when I try to add this as a scheduled task in Windows I get the following error:
foo : The term 'foo' is not recognized as the name of a cmdlet, function, script file, or operable program.
How can I fix the script to allow it to run as a Windows Scheduled Task?