feel like I am going to laugh/Cry because I know that I am doing something stupid/obviously incorrect.

I am using SCCM and PSADT to attempt the below. It works fine if I UNC to the target folder and run the script but the below happens when deployed in SCCM

I have tried every variation of the below that I can think of. I am trying to move a directory from a networked VM to a local client but all I can seem to do is copy the EMPTY directory itself

examples of what I have tried are

If (!(Test-Path("C:\Target\"))) {
            New-Item -ItemType directory -Path "C:\Target"
            Copy-Item -Path "$dirFiles\Target\*" -Destination "C:\Target\" -Recurse -Force -Verbose


  If (!(Test-Path("C:\Target\"))) {               
                Copy-Item -Path "$dirFiles\Target" -Destination "C:\" -Recurse -Force -Verbose

And everything in between I can think of. Each time I just get the empty directory folder created but none of the contents

  • I brought the target up a level to "$dirTarget" and it worked. Is SCCM unable to go 2 levels down or should I always have had the script like that?
    – user001
    Mar 9, 2018 at 10:11
  • It's unclear what you're attempting "I am using SCCM and PSADT to attempt the below." and what your current code looks like. Currently your variable $dirFiles is undefined.
    – Seth
    Mar 9, 2018 at 10:16
  • It's part of a much larger toolkit which calls correctly for every other app. it defines the variables correctly (allowing me to access when running locally and on all other deployed Apps). I can see the folder being created in the destination directory but it is empty, the recursion is not taking
    – user001
    Mar 9, 2018 at 10:21

1 Answer 1


Sounds like a permissions issue. As you're running from SCCM, I would guess that you're using the pre-release Run Script feature. This runs the script as the computer's Local System account, which likely doesn't have the correct NTFS permissions to your network share.

If you're on a domain: As a quick, (dirty&insecure - revert this change immediately after testing!) test. Give Domain Computers read access to the $dirFiles\target folder and all child objects. If it works, you need to figure either:

  • How you want to structure access permissions for Local System accounts
  • Whether to turn script into a package or application and run as the logged in user instead.

The package option is safer, but a bit more long-winded.

Good luck

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .