使用 PowerShell 将文件远程复制到 SharePoint 服务器
要求:
在品牌项目期间,我们每次都必须通过单独登录到所有 SharePoint 服务器并将给定文件复制粘贴到所有 SharePoint 2013 服务器的 15 个配置单元来将徽标文件部署到所有 SharePoint 服务器。想在这里使用 PowerShell 进行一些自动化操作。让 PowerShell 为我们执行复制粘贴操作。
用于将文件远程复制到服务器的 PowerShell 脚本:
$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
}
您可以从工作站运行此脚本。只需确保运行此脚本的帐户对列出的所有服务器都具有管理员访问权限。