Copying Multiple Folders Using PowerShell.txt - Notepad

Copying Multiple Folders Using PowerShell

The below PowerShell script uses the copy-item cmdlet to copy a list of UNC paths stored in a CSV file to a new destination. Ensure that the first cell in the CSV file is named 'name'. The recurse parameter ensures that child folders and files are included in the copy. You can use the -force parameter to overwrite an existing identically named folder in the destination location.
$dirlist=import-csv C:\dirs.csv

ForEach ($path in $dirlist) {

$name=$path.name

copy-item -path $name -recurse -destination \\hostname\c$\destination_dir

}

Back