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 07 '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 07 '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 07 '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 07 '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 07 '16 at 15:50

1 Answers1

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

Nick Young
  • 688
  • 4
  • 14
  • Thanks Nick Young! The Executionpolicy resolved the issue! – Roger Erni Jan 11 '16 at 08: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