Copy file to all SharePoint farm server using PowerShell
If you have a SharePoint Farm and you need to update only one file, for example, in LAYOUTS dir (c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\...), there’s no need to go to every server and copy file.
Using PowerShell and some strings of code below you can easily do it.
Copy File to SharePoint farm servers
#PowerShell script to copy file to SharePoint Farm servers
#Path and filename of source file
$source = "C:\distrib\CustomAlertTemplates.xml"
#UNC paths for each server
$pc1 = "\\PC1\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\"
$pc2 = "\\PC2\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\"
$pc3 = "\\PC3\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\"
Copy-Item -LiteralPath $source -Destination $pc1
Copy-Item -LiteralPath $source -Destination $pc2
Copy-Item -LiteralPath $source -Destination $pc3
Of course, you may optimize this script. You can add cycles, paths or whatever you want. But if you need just to overwrite or add file several times, you can use this script. It's enough. The only requirement is you need to execute this script on a machine with opened ports in firewall to servers and account who can change files on SharePoint servers.
No Comments »
No comments yet.
RSS feed for comments on this post. TrackBack URL