I have a scheduled task to run a powershell script on a Win 2019 server to export documents changed in last day. I use Get-PWDocumentsBySearchWithReturnColumns start and end dates then Export-PWDocuments to accomplish this.
However I have only been successful in running it when the user is logged "on".
I have tried "Run whether user logged on or not", "Run with Highest Privileges" and have the following switches on the executable -executionpolicy bypass -noninteractive -File "C:\MyScript.ps1"
Not sure if this is due to the PW search that will only run in a "logged on" user instance? When logged on runs fine.
Any input would be appreciated, thanks
How are you running the scheduled task? Are you using the local service account?
Presently the Administrator account
How are you logging into the datasource in the script?
Do you do any logging in the script to see if it launches and how far it gets?
New-PWLogin using logical account detail for the purpose.
Yes I am logging Start-Transcript/Stop..., I will check again, but I believe it doesn't log anything. The scheduled task fails with 0x41301 (?) will check again, script running at present, using only when logged on.
Update when done
Hmmm, that status just means the task is running. Generally i see that right off the bat when i have a task that is prompting for input so it's just sitting around waiting.
Try logging into the computer using the account you have the scheduled task running as and trying running manually again.