Copy Files using PowerShell

A colleague today asked me how can he copy a file to approx. 150 servers using PowerShell… Its a pretty simple thing to do, so here’s the code.

We used a list of servers from a file called servers.txt and then used the Copy-Item cmdlet to copy the file to the destination server. Very, very simple.

 

$servers = get-content “C:\servers.txt”
foreach ($server in $servers)
{
Copy-Item -Path ‘C:\filetocopy.txt’ -Destination “\\$server\e$\Folder\”
}

 

 

 
Comments

No comments yet.

Leave a Reply