As an Exchange Administrator, working with many Exchange Servers is not uncommon but when you have to deal with copying the latest Security Update (SU), Cumulative Update (CU) or updated SSL Certificates, it can be a tedious task to do it all manually.
Luckily we have PowerShell that can help with this process by taking the download and copying it to multiple servers. I put together a script that needs some manual changes done and this includes the following:
- $SourceFilePath – The path to the file you want to copy the file from
- $DestinationServers – All the servers that you want to copy the file to
Below is the output from copying a file to my three (3) Exchange Servers:
Script
The script is straight forward, can be saved as a PS1 file or run straight from PowerShell ISE, PowerShell 7 or Standard PowerShell. Here is the script:
# Define the source file path
$sourceFilePath = "\\SourceServer1\c$\Installs\FileName.ext"
# Define an array of destination servers
$destinationServers = @(
"\\Server1\C$\Installs\"
"\\Server2\C$\Installs\"
"\\Server3\C$\Installs\"
# Add more server paths as needed
)
# Loop through each destination server and copy the file
foreach ($destinationServer in $destinationServers) {
$destinationPath = Join-Path $destinationServer (Split-Path $sourceFilePath -Leaf)
Copy-Item -Path $sourceFilePath -Destination $destinationPath -Force
Write-Host "File copied to $destinationPath"
}
I hope it helps save you time doing the mundane tasks of having to copy setup files.