Copy Large Number of Files Using PowerShell

Ray Turner
Ray Turner used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Active Directory/Exchange Engineer
Top Expert 2015
Commented:
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
Example
robocopy <Sourcepath> <Destinationpath> /s /e /copyall

ref link: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
RobertSystem Admin

Commented:
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

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

https://gallery.technet.microsoft.com/scriptcenter/Copy-Files-from-folderA-to-29710ef9

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

Author

Commented:
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