I have a simple powershell script to get the names in a directory and write it into a file . I want this to be executed daily at 8:00AM so I created a task for it from the Windows task scheduler the task scheduler is able to.start the script but the script is unable to.write into a file. So as an alternative I created a batch file and I tried to invoke the ps1 using the task scheduler this is giving an error "fileopenerror" My batch file has \PowerShell.exe \test.ps1
My PowerShell script has Set-executionpolicy -scope currentuser -executionpolicy remotesigned -force ls >> names.txt