0

I am trying to schedule a task which runs a powershell script. This script copy several files from one server to the one which the script is running.

If i run the script with an elevated powershell prompt it is working like a charme. When I create a scheduled task with the same user as I used for running manual directly, the script isn't working anymore because the script isn't able to find the folders. Oddly enough there is no error shown in the task scheduler.

If I log on to the system with the same user, there are no problems connecting the shares.

We have allready tried to permit the user same like our domain admin. Still no luck.

My guess is there is something in the security policy wrong. We allready set the logon as a batch job and the log on locally policy.

Any suggestions?

  • Do you have the check mark for "Run with highest privileges" checked? Are you using a drive letter or a UNC path? I've had better results using a UNC path to the source. – Nixphoe Jan 7 '16 at 14:11
  • Within the script, add "start-transcript c:\temp\xyz.log" at the top, and "stop-transcript" at the bottom. After script has run, what's in the transcript? – Clayton Jan 7 '16 at 14:13
  • I've tried the "Run with highest privileges" without success. We are using drive letters (d$) and UNC Paths. Both same result. This is the output using Task Scheduler or directly running: ********************** Windows PowerShell Transcript Start Start time: 20160107155212 Username : PFS\svc_abacus_copy Machine : PFSVSV011 (Microsoft Windows NT 6.1.7601 Service Pack 1) ********************** Transcript started, output file is C:\temp\xyz.log ********************** Windows PowerShell Transcript End End time: 20160107155212 ********************** – Roger Erni Jan 7 '16 at 14:55
  • Simplify this issue first. Change the source and destination to something both local and see if the same thing happens. – Drifter104 Jan 7 '16 at 15:44
  • I have allready tried that. Same result if i copy from one folder to a sub folder on the same system. – Roger Erni Jan 7 '16 at 15:50
0

There's a check box to not save password. Network resources including shares won't work if you don't have it save the password.

Also ensure your using -executionpolicy bypass.

Application: powershell.exe Parameters: -f script.ps1 -executionpolicy bypass

  • Thanks Nick Young! The Executionpolicy resolved the issue! – Roger Erni Jan 11 '16 at 8:34
  • Great. If you find my answer complete mark it as such. If someone else's was more helpful mark theirs. Also don't forget to up vote anything you found helped troubleshooting so others can find the answers they need. – Nick Young Jan 11 '16 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.