July, 2018

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.