Needed a quick way to copy a file across a Windows terminal server environment. Kept having issues where a new directory would not be created if it wasnt there already. Very simple code as I am a very simple minded.
$server_names = @("serv1","serv2","serv3","serv4","serv5")
Foreach ($server in $server_names){
Copy-Item "file_to_be_copied.txt" -Destination (New-Item "\\$server\C$\New_Directory_to_be_created" -Type container -Force) -Force
}