Updated PowerShell Script to Distribute Scripting Agent Configuration File to Exchange Servers

When you’ve enabled the Exchange scripting agent extension agents, it is required to copy the configuration file to each Exchange server. Paul Cunningham’s script helps you to achieve this goal pretty easily.

But if you have installed the Exchange 2013 Management Tools on additional servers, these servers are not fetched using the Get-ExchangeServer cmdlet. But when you install a Cumulative Update the existence of the extension agent config file is checked. And this is even on a server having only the Exchange Management Tools installed.

Therefore the following PowerShell code provides an easy and simple way to add additional servers having the Exchange 2013+ Management Tools installed (aka Admin Servers, Monitoring Servers, Job Servers, etc.). The script uses a filter to select Exchange 2013 servers only, as the script has been extended in an environment having still active Exchange 2007 servers.

The following PowerShell snippet displays only the changes, which need to be added to Paul’s original script starting row 68.

# Original PowerShell code# 
$exchangeservers = Get-ExchangeServer

# Select all Exchange 2013 servers only, restrict properties to Name and AdminDisplayName
$exchangeservers = Get-ExchangeServer | Where-Object { $_.AdminDisplayVersion -like "Version 15.0*" } | Select-Object Name, AdminDisplayVersion

# Add additional servers as needed
$manualServers = @()

# Copy and modify as needed
$manualServers += (New-Object PSObject -Property @{Name = "EXSRV2010"; AdminDisplayVersion = "Version 14" })
$manualServers += (New-Object PSObject -Property @{Name = "EXSRV2013-01"; AdminDisplayVersion = "Version 15" })
$manualServers += (New-Object PSObject -Property @{Name = "EXSRV2013-02"; AdminDisplayVersion = "Version 15" })

# Combine arrays
$exchangeservers = $exchangeservers + $manualServers

# End Modification
$report = @()
[string]$date = Get-Date -F yyyyMMdd-HHmmss

Enjoy extending the Exchange PowerShell cmdlets.

Links

Enjoy Exchange Server.

%d Bloggern gefällt das: