Scenario: You want to install Microsoft’s Unified Communications Managed API 4.0 to multiple servers remotely
Script:
- Collect your Servers by Querying AD
Import-Module ActiveDirectory $strOU = "OU=Exchange2016,DC=XYZ,DC=COM" $servers = get-adcomputer -searchbase $strOU -properties Name -Filter *| where {$_.name -like "Ex16-*"} | Select -ExpandProperty Name
2. Copy your Installer File to a folder on each server (or a single network share). We have copied it to C:softwareUCMA.exe on each Exchange Server.
3. Run the Installer by invoking the command on each server.
$servers | %{"Installing UCMA on $_"; Invoke-Command -Computer $_ -ScriptBlock { #Set Variables $file = "C:softwareUcma.exe" #check to see if its installed if (Get-ItemProperty "HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstallUCMA4" -ErrorAction SilentlyContinue) { Write-host "Unified Communications Managed API 4.0 Runtime is already installed." -ForegroundColor Cyan } else { #testing If (Test-Path $file){ Write-host "The installer file exists:$file" -ForegroundColor Green #Installing Write-Host "Installing Microsoft UM API..." -ForegroundColor yellow $arg = "/quiet /norestart" $status = (Start-Process $file -ArgumentList $arg -Wait -PassThru).ExitCode if ($status -eq 0) { write-host "Successfully installed $file" -ForegroundColor Green } if ($status -ne 0) { write-host "Failed!" -ForegroundColor Red } } else {Write-host "$file does not exist" -ForegroundColor red} } }}