Author Topic: [Powershell]Copy file to new directory across network farm  (Read 628 times)

0 Members and 1 Guest are viewing this topic.

Offline 0E 800

  • Not a VIP
  • VIP
  • Baron
  • *
  • Posts: 895
  • Cookies: 131
  • • тнε ιηтεяηεт ιs мү яεcүcℓε-вιη •
    • View Profile
[Powershell]Copy file to new directory across network farm
« on: 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.

Code: (powershell) [Select]
$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
}
The invariable mark of wisdom is to see the miraculous in the common.