This is untested, but see if it works. It assumes that files.txt
, servers.txt
, and all source files are in the same directory as the script file itself.
$ServerList = Import-Csv -Path $PSScriptRoot\servers.txt -Delimiter ' ' -Header 'Name', 'CopyFiles';
$FileList = Get-Content -Path $PSScriptRoot\files.txt;
foreach ($Server in $ServerList) {
if ($Server.CopyFiles -eq 'Yes') {
foreach ($File in $FileList) {
Copy-Item -Path "$PSScriptRoot\$File" -Destination ('\\{0}\Projects\MyProject\{1}' -f $Server.Name, $File);
}
}
}