EvilZone

Programming and Scripting => Scripting Languages => : 0E 800 November 04, 2015, 01:27:43 AM

: [Powershell]Copy file to new directory across network farm
: 0E 800 November 04, 2015, 01:27:43 AM
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.

: (powershell)
$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
}