I'm trying to learn about task scheduling in Windows 10, so I set myself the task of trying to schedule a script that writes a blank file called test.txt
to the user's home directory.
I did this by creating a task that executes Out-File -FilePath $HOME\test.txt
:
However, when I try to execute this task manually I see some errors:
I've also confirmed that the test.txt
file wasn't created. The error description looks like this:
Task Scheduler failed to launch action "Out-File" in instance "{32b4ec9b-49e8-441a-852d-8332f0a118d5}" of task "\TestTask". Additional Data: Error Value: 2147942402.
According to another SF question This issue is caused by a "File Not Found" error. I thought maybe it couldn't find the Out-File
command so I tried changing the command to echo "test" >> $HOME\test.txt
but this didn't seem to have any effect.
What am I doing wrong here?