PowerTip: Use PowerShell to Copy Source to Multiple Destinations

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.

Comments (2)

  1. MikeM says:

    Awesome, handy and very useful single line concept. I can think of many administrative applications. Thanks – very much appreciated. MM

  2. OldFart says:

    You can alternatively do this:

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

Skip to main content