ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Robocopy script not running from task scheduler

    IT Discussion
    windows 2012 r2 robocopy powershell
    7
    22
    4.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jmooreJ
      jmoore @Obsolesce
      last edited by

      @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

      1 Reply Last reply Reply Quote 0
      • RomoR
        Romo @Obsolesce
        last edited by

        @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??

        ObsolesceO 1 Reply Last reply Reply Quote 0
        • RomoR
          Romo
          last edited by

          Ok finally something new, apparently something is wrong with the destination folder as I am getting:
          Screenshot from 2019-04-02 19-00-38.png

          So through Task scheduler it cant write to the destination folder for some reason.

          EddieJenningsE 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller
            last edited by scottalanmiller

            For Google: "ERROR 19 (0x00000013) Accessing Destination Directory. The media is write protected."

            1 Reply Last reply Reply Quote 0
            • EddieJenningsE
              EddieJennings @Romo
              last edited by

              @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:
              Screenshot from 2019-04-02 19-00-38.png

              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.

              RomoR 1 Reply Last reply Reply Quote 0
              • ObsolesceO
                Obsolesce @Romo
                last edited by

                @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.

                jmooreJ RomoR 2 Replies Last reply Reply Quote 1
                • jmooreJ
                  jmoore @Obsolesce
                  last edited by

                  @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.

                  ObsolesceO 1 Reply Last reply Reply Quote 0
                  • ObsolesceO
                    Obsolesce @jmoore
                    last edited by Obsolesce

                    @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!

                    jmooreJ 1 Reply Last reply Reply Quote 0
                    • jmooreJ
                      jmoore @Obsolesce
                      last edited by

                      @Obsolesce Oh thats interesting. I'm not familiar with it. I will look at that when I get time, thanks.

                      1 Reply Last reply Reply Quote 0
                      • RomoR
                        Romo @EddieJennings
                        last edited by

                        @EddieJennings yes destination has enough storage, shares are writable as well as running the script manually works without an issue.

                        1 Reply Last reply Reply Quote 0
                        • RomoR
                          Romo @Obsolesce
                          last edited by

                          @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.

                          1 Reply Last reply Reply Quote 0
                          • 1
                          • 2
                          • 2 / 2
                          • First post
                            Last post