Powershell script copy files multiple servers




















Then the script will do the following:. You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in. Products 72 Special Topics 41 Video Hub Most Active Hubs Microsoft Teams. Security, Compliance and Identity. Microsoft Edge Insider. Azure Databases. Autonomous Systems. Education Sector. Microsoft Localization.

Microsoft PnP. Healthcare and Life Sciences. Internet of Things IoT. Enabling Remote Work. Small and Medium Business. As you can see from the above, we have defined the full path of the example. I prefer a slightly more sophisticated solution — we can use the Get-Content cmdlet or gc for short to get the contents of a text file called servers.

This text file simply contains a list of servers, each on a new line. We can pass each line of the contents of servers. The script below will achieve this:. Another approach to the above code example is the following without using external text files to define destination servers :. Another approach to copy a single file on multiple systems is by using Invoke-Command that will handle all the parallel processing.

You can modify the -ThrottleLimit parameter on Invoke-Command to change how many copies it does at the same time. The default is The following is an example code to use this approach the source-server is the server from which the file will be copied on destination servers :. The destination is local since you are running the command from the destination server.

You don't need Read-Host. Not sure what you are trying to do on the last line though Add a comment. Active Oldest Votes. BenH BenH 9, 1 1 gold badge 16 16 silver badges 31 31 bronze badges.

I agree, it's hard to know what was intended, but I have updated the script with what I think was intended — BenH. Sign up or log in Sign up using Google.

Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.



0コメント

  • 1000 / 1000