1

I want to copy the folder structure only (no data) and preserve the ACL from the source

I know that my code will copy the files over.

$sourceDir = "\\Server\Path"
$targetDir = "\\Server2\Path"
Get-ChildItem -Path $sourceDir | Copy-Item -Destination $targetDir -Recurse -Container

robocopy and xcopy is not allowed in our organization. I don't know why but it's not. I'd rather not use the GUI to manually create folders/subfolders.

1
  • 2
    What do you mean by "robocopy is not allowed"? It's a Windows built-in tool. What's not allowed about that? Commented Jun 21, 2017 at 15:27

1 Answer 1

2

Using -Filter {PSIsContainer} will only copy Directories:

$sourceDir = "\\Server\Path"
$targetDir = "\\Server2\Path"
Copy-Item $sourceDir $targetDir -Filter {PSIsContainer} -Recurse -Force
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.