Copy files to Remote computers using powershell

Hi SysAdmins

In an earlier post I described – How to copy files to domain member computers or servers using Group Policy Object (GPO).

In this post I will show how to copy files to remote computers or servers using a simple Powershell script and .txt file.


All you need is:

A txt file that looks like this:
and so on…

You can use IP addresses as well.

And this piece of Powershell code:

$ServerList = Get-Content "C:\ServersList.txt" #Change this to location of servers list
$SourceFileLocation =  #For example: D:\FoldertoCopy\ or D:\file.txt
$Destination =  #Example: C$\temp

foreach ($_ in $ServerList)
 {Copy-Item $SourceFileLocation -Destination \\$_\$Destination -Recurse -PassThru}

Save the above code as CopyFilestoservers.ps1, and your servers list as ServersList.txt

You will need Write permissions on the remote machines to run the script successfully.

Leave a Reply