SCCM Run Script File Copy Example

New to the Scripts feature however I'm enjoying it. I needed a script that could copy files from a network folder to the local machine

To import this script first download it from https://1drv.ms/u/s!Apq2Xflj18I19CAcc9kmVDFsILIN

In the SCCM Console under Software Library \ Scripts

Right click and choose Create Script

Click Import and select the Script

Click Next, then customise each script parameter with the following

Friendly Name: Source Folder
Description: Network folder path that computer account has read access to
Regular Expression: .+[^\\]$
Custom Error: Please remove end backslash

Friendly Name: Destination Folder
Description: Folder path on C:
Regular Expression: .+[^\\]$
Custom Error: Please remove end backslash

Click Next, Next, Close

Right click, Approve.

 

SCCM seemed not to like paths with backslashes at the end so added regEx.
File-Copy Command is buggy when a folder exist so used some other code to fix that.
I still need to apply the latest SCCM patch to test folder paths with spaces - Bug in 1802, parameters with spaces don't work.

5 Comments

  1. Carlos Alba July 18, 2019 Reply

    Hi

    your script works like a charm running on ISE ...

    But from SCCM console ... exits with code 0 but no folders or files are copied ...

    What could it be ? Log files does not give much more ...

    Thanks in advance

    • Author
      Jay Connor August 1, 2019 Reply

      It would be that the machine you are running on doesn't have access to the files.

  2. Christopher May 20, 2020 Reply

    Works great in my SCCM environment to dump a huge Autodesk folder to install Civil 3D 2018 but after the files are dumped into the folder I specify I noticed that the script status in ConfigMgr keeps scrolling across with creating client jobs. I'm thinking it needs a detection or exit code in the script?

  3. I did it this way

    Copy-Item -Path "\\[NETWORK PATH]" -Destination "[DESTINATION PATH]" -Recurse

    Works like a charm

    • Author
      Jay Connor February 3, 2023 Reply

      Nice! I hadn't looked at it again as I wasn't using it. Good work

Leave a Comment

Your email address will not be published. Required fields are marked *

*