Copy Large Number of Files Using PowerShell

Ray Turner
Ray Turner used Ask the Experts™
How do you use PowerShell to copy all files in a directory (with all sub-folders) on the drive to another drive?

For example

xcopy c:\test\*.* d:\test /s
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Active Directory/Exchange Engineer
Top Expert 2015
Your best bet will be to use robocopy with the switch to copy all subfolders and to keep the same security settings of the original folder
robocopy <Sourcepath> <Destinationpath> /s /e /copyall

ref link:
RobertSystem Admin

I agree with Fox Robocopy is the way to go.
However if you need to do it with powershell for some reason the Copy-Item command using the -Recurse option would copy all sub folders.
Jose Gabriel Ortega CastroTop Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018

I've been trying to substitute robocopy and xcopy with my PowerShell script :)

So I'd go and use my script.
Ray TurnerSenior Consultant


Thanks!  This is great!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial