Robocopy script not running from task scheduler
-
@JasGot In the script file you mean?
-
It does run without trouble when running directly though, so not sure about a syntax error.
-
@Romo said in Robocopy script not running from task scheduler:
It does run without trouble when running directly though, so not sure about a syntax error.
Is the server it is running on a DC?
Does it fail to run if logged in or not logged in?
-
@JasGot Yes, it is actually the DC server. From task scheduler I have tried it logged in as the same account that is running the script and from a different user account with the script user not logged in at all.
-
Have you tried using
Bypass
instead ofUnrestricted
? -
@black3dynamite Yes =(
-
@Romo said in Robocopy script not running from task scheduler:
@JasGot Same account currently as the user running the script manually. Also forgot to mention it had been working before without adding net use and the UNC until someone else tried to make a modification.
If it was working before and then stopped working when nothing was changed, that smells like a Windows update messed things up.
-
@Obsolesce Would have to agree there. I do this on many machines here and at first glance it sure looks right. I;m not running from a dc though
-
@Obsolesce said in Robocopy script not running from task scheduler:
@Romo said in Robocopy script not running from task scheduler:
@JasGot Same account currently as the user running the script manually. Also forgot to mention it had been working before without adding net use and the UNC until someone else tried to make a modification.
If it was working before and then stopped working when nothing was changed, that smells like a Windows update messed things up.
Yeah, it could be a possibility. Something in the task was changed though but not sure exactly what was changed. We were told a couple of days after it had stopped working.
What I really find strange is that the scripts works just fine when manually run. We must be missing something somewhere that makes the script fail on task scheduler.
Maybe when running through task scheduler it can't access the credentials in Credential manager until something is executed beforehand??
-
Ok finally something new, apparently something is wrong with the destination folder as I am getting:
So through Task scheduler it cant write to the destination folder for some reason.
-
For Google: "ERROR 19 (0x00000013) Accessing Destination Directory. The media is write protected."
-
@Romo said in Robocopy script not running from task scheduler:
Ok finally something new, apparently something is wrong with the destination folder as I am getting:
So through Task scheduler it cant write to the destination folder for some reason.
Does the destination path have enough storage? If the path is an external drive, make sure it's not showing as read-only in Disk Management.
-
@Romo said in Robocopy script not running from task scheduler:
Maybe when running through task scheduler it can't access the credentials in Credential manager until something is executed beforehand??
If you are running your script as SYSTEM, the credentials need to be put into Credential Manager as SYSTEM.
For example, use PSEXEC to run powershell as SYSTEM, then you can add credentials to Credentail Manager and call them from PowerShell using the CredentialManager PowerShell module.
-
@Obsolesce This kind of what I do. I had too many problems with credentials in windows and powershell so I just started psexec within powershell to bypass a lot of that trouble. Works better for me anyway.
-
@jmoore said in Robocopy script not running from task scheduler:
@Obsolesce This kind of what I do. I had too many problems with credentials in windows and powershell so I just started psexec within powershell to bypass a lot of that trouble. Works better for me anyway.
I meant that in the scenario that you use a Scheduled Task to run a PowerShell script as SYSTEM... in that case, when it looks for credentials in Credential Manager, itwon't find them, unless you add credentials to Credential Manager AS the SYSTEM account, which means you need to be running PowerShell interactively as SYSTEM.
What I've been doing lately is working with Azure Automation PowerShell Runbooks, which has it's own Credential Manager.... which basically works identically to the CredentialManager PS module. So if you use that you don't even need a Windows box. Also, you can simply have a parameter in your PowerShell Runbook to accept webhook that executes the runbook... which is freakin sweet! It's great for building API flows between Azure/Intune/etc and 3rd party services!
-
@Obsolesce Oh thats interesting. I'm not familiar with it. I will look at that when I get time, thanks.
-
@EddieJennings yes destination has enough storage, shares are writable as well as running the script manually works without an issue.
-
@Obsolesce Haven't tried it by running it directly as SYSTEM, it has been run as a user and checked to be run with the highest privileges. As it was when it was working before.