If you are looking for a simple script to copy files across multiple remote computers then you are at the right place, in this article we explain with a simple powershell code.
when user or administrator wants to copy the files from a source location to a remote location or remote computer then you are at the right place, it’s easy, this article explains how one can achieve with a simple PowerShell script.
Assuming you have access to remote computers, meaning you are able to login with your login id or corporate ID to remote machines where you want to copy files and also C UNC path is enabled, most of the servers or desktop machines this C drive UNC path is enabled, here is the script.
Copy files to A Single Server or Desktop
Copy-Item -Path "\\machine1\c$\softwares\adobe" -Destination "\\machine2\c$\softwares"
The above example line of PowerShell code copies the files from machine1 to machine2.
Copy files to Multiple Computers or Desktops
When you have a requirement to Copy files on multiple remote machines, then we need to write the script this way.
Let’s see how to remove a local account on multiple remote computers.
We need to create a file for storing all the servers or multiple machines list, I named it as Allservers.txt for and saved it in my local machine c:\temp\Allservers.txt
#remote machines list $machines= Get-Content -Path "C:\temp\AllServers.txt" foreach ($onemachine in $machines) { Write-Host "Currently the script is copying files on" $server Copy-Item -Path "\\sourcemachine\c$\softwares\adobe" -Destination "\\$onemachine\c$\temp" -Recurse }
In the above script example, we are copying files to multiple machines from source locations as source machine to all other machines in C:\temp directory.
you can change the location as per your need, this is a very effective way you can copy files over multiple machines.
when you want to override the files the new files at the destination simple use the below code.
Copy-Item -Path "\\sourcemachine\c$\softwares\adobe" -Destination "\\$onemachine\c$\temp" -force -Recurse
Conclusion:
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
This was very easy and I was able to resolve my issue quickly with this post. I had looked at several and was not able to resolve my Access denied issue, but after review this post I was able to figure out what the issue was.
GREAT work!!!!!!