March 11th, 2015

PowerTip: Use PowerShell to Copy Source to Multiple Destinations

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to copy a source directory to multiple destinations.

Hey, Scripting Guy! Question How can I use Windows PowerShell to make multiple backup copies of a source directory without wasting a
           lot of time mousing around?

Hey, Scripting Guy! Answer Copying a single source directory to multiple destinations can be a single line command, for example:

"c:\fso1","c:\fso2","c:\fso3" | % {Copy-Item c:\fso -Recurse -Destination $_}

Note  The % symbol is an alias for the Foreach-Object cmdlet.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback