TheHighlanders
asked on
Schedule Task fails to run
Windows server 2012R2, running a schedule task to call a PowerShell script. Script runs fine if manually started. Task runs fine if in the GENERAL tab I select "Run only when user is logged on".
Does NOT run if I select "Run whether user is logged on or not"
Account has permissions to script, location, destination. Passwords are correct. Account is a domain admin account
ACTIONS:
Program\Script: %SystemRoot%\system32\Wind owsPowerSh ell\v1.0\p owershell. exe
Add arguments (options): C:\Scripts\DailyNAS.ps1
HISTORY:
100: Task Started (1)
200 Action Started (1)
110 Task triggered by user Info
210 Action Completed (2)
102 Task Completed (2)
All History items happen within 1 second, the script is to run a 110GB Backup from file server to NAS. No folder is created, and no 110GB backup happens in less than 1 sec.
If anyone can help I'll email you a cookie :-)
Does NOT run if I select "Run whether user is logged on or not"
Account has permissions to script, location, destination. Passwords are correct. Account is a domain admin account
ACTIONS:
Program\Script: %SystemRoot%\system32\Wind
Add arguments (options): C:\Scripts\DailyNAS.ps1
HISTORY:
100: Task Started (1)
200 Action Started (1)
110 Task triggered by user Info
210 Action Completed (2)
102 Task Completed (2)
All History items happen within 1 second, the script is to run a 110GB Backup from file server to NAS. No folder is created, and no 110GB backup happens in less than 1 sec.
If anyone can help I'll email you a cookie :-)
If you create a scheduled task which starts notepad under specific user - will it run?
ASKER
Just tried. yes it does, notepad launched first time.
Thanks
Also "Run with highest privilege" is TRUE
Run as Server 2008 R2: TRUE
Thanks
Also "Run with highest privilege" is TRUE
Run as Server 2008 R2: TRUE
Now, if you replace the start of the notepad with your script - will it run? I guess the task for script is running under local admin, right?
ASKER
Just tried, didn't run, have tried to create a brand new task in case I messed something up, still not working.
Have tried Local Admin and Domain Admin.
Can copy & paste script startup params to "run" and it kicks off fine.
Have tried
powershell -file "C:\Scripts\DailyNAS.ps1"
Also the param in the O.P.
both work fine when ran manually, or with "Run only when user is logged on" radio button ticked.
Have tried the "Start in (optional)" as I have seen this suggested in places with C:\Scripts but this also fails.
Have tried Local Admin and Domain Admin.
Can copy & paste script startup params to "run" and it kicks off fine.
Have tried
powershell -file "C:\Scripts\DailyNAS.ps1"
Also the param in the O.P.
both work fine when ran manually, or with "Run only when user is logged on" radio button ticked.
Have tried the "Start in (optional)" as I have seen this suggested in places with C:\Scripts but this also fails.
Some resources aren't available unless a user is logged in. We'd really have to see the script to determine if that's the case.
ASKER
It's just a robocopy script with multiple lines.
robocopy "\\SAS-DC\Data\Corresponda nce - client" "y:\Daily\Correspondance - client" /s /e /mir /R:1 /W:1
Y: is a mapped drive to the NAS
The NAS is a non domain joined NAS, Buffalo terastation.
robocopy "\\SAS-DC\Data\Corresponda
Y: is a mapped drive to the NAS
The NAS is a non domain joined NAS, Buffalo terastation.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
update: have tried the script with:
robocopy "\\SAS-DC\Data\Corresponda nce - client" "\\192.168.1.6\Daily\Corre spondance - client" /s /e /mir /R:1 /W:1
In case it was having problems with hte mapped drive letter when not logged on. Still fails :-(
robocopy "\\SAS-DC\Data\Corresponda
In case it was having problems with hte mapped drive letter when not logged on. Still fails :-(
ASKER
Thanks very much, it was add code in the script to remove the currently mapped drive, and remap with credentials and workgroup name and drive letter.
you sir\madam are a hero!!!!
Used these lines:
net use y: /delete
net use y: \\192.168.1.6\Daily <PASSWORD> /USER:workgroup\admin /persistent:yes
robocopy "\\SAS-DC\Data\Corresponda nce - client" "y:\Daily\Correspondance - client" /s /e /mir /R:1 /W:1
etc...
etc...
etc...
you sir\madam are a hero!!!!
Used these lines:
net use y: /delete
net use y: \\192.168.1.6\Daily <PASSWORD> /USER:workgroup\admin /persistent:yes
robocopy "\\SAS-DC\Data\Corresponda
etc...
etc...
etc...
I'm glad it worked out, TheHighlanders. Have a good one!