So I actually adapted this from an Exchange 2010 script I just wrote to do the same thing. Say it’s time to install a CU/RU, service pack, or some other addon that requires binaries be installed on all SharePoint servers. There are a few ways you can do this.

  • Manually copy all the files through windows explorer.
  • use robocopy commands that copies the folder. each server would have it’s own robocopy command.
  • SharePoint 2010 and Exchange 2010 allow us to get a list of the servers in the environments. We can use powershell with robocopy to programatically push the install folder to the servers.
The two scripts are virtually identical with the exception of how the list of servers is acquired. SharePoint uses get-spserver while exchange uses get-exchangeserver.
I also added an if statement to make sure it doesn’t bother trying to copy the files to itself.

SharePoint 2010

The script doesn’t actually directly reference any servers in the environment so it’s completely portable.

$servers = Get-SPServer | where {$_.role -ne "Invalid"}

foreach ($server in $servers) {
    if ($server.address -ne $env:COMPUTERNAME) {
		$name = $
        robocopy \\$env:COMPUTERNAME\e$\_Installs \\$name\e$\_Installs /MIR /FFT /Z /XA:H /W:5 /r:2


Exchange 2010

Again no environment specific information is used so it’s portable.

$servers = Get-ExchangeServer

foreach ($server in $servers) {
    if ($ -ne $env:COMPUTERNAME) {
        robocopy \\$env:COMPUTERNAME\C$\_Install \\$server\c$\_Install /MIR /FFT /Z /XA:H /W:5 /r:2