Link to home
Start Free TrialLog in
Avatar of TheHighlanders
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\WindowsPowerShell\v1.0\powershell.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 :-)
Avatar of noxcho
noxcho
Flag of Germany image

If you create a scheduled task which starts notepad under specific user - will it run?
Avatar of TheHighlanders
TheHighlanders

ASKER

Just tried. yes it does, notepad launched first time.
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?
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.
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.
It's just a robocopy script with multiple lines.

robocopy "\\SAS-DC\Data\Correspondance - 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.
ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
update: have tried the script with:

robocopy "\\SAS-DC\Data\Correspondance - client" "\\192.168.1.6\Daily\Correspondance - 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 :-(
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\Correspondance - client" "y:\Daily\Correspondance - client" /s /e /mir /R:1 /W:1
etc...
etc...
etc...
I'm glad it worked out, TheHighlanders. Have a good one!