kwizcom banner advertisement

Copy Files to SharePoint Servers Remotely using PowerShell

Requirement:
During a branding project, We had to deploy a logo file every time to all SharePoint servers by individually logging in to them and copy pasting given file to all SharePoint 2013 server's 15 hive. Wanted to do a bit automation with PowerShell here. Let the PowerShell do Copy-Paste for us.

PowerShell script to copy files to Servers:
$LogoPath = "D:\Branding\crescent-logo.png" 

#Define Array with List of servers
$WFEServers = ("G1V-SPS13001", "G1V-SPS13002", "G1V-SPS13003", "G1V-SPS13004", "G1V-SPS13005")

foreach ($Server in $WFEServers)
{
      #Destination path
      $Destination = "\\$Server\C$\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES\crescent-logo.png"

      #Copy File from local to destination
      Copy-Item $LogoPath $Destination

      write-host "Copied to Server:"$Server
} 
You can run this script from your workstation. Just make sure the account in which you are running this script has Admin access on all of the servers listed.
Copy Files to SharePoint Servers Remotely using PowerShell Copy Files to SharePoint Servers Remotely using PowerShell Reviewed by Salaudeen Rajack on February 20, 2014 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.