Quantcast
Channel: Practical 365
Viewing all articles
Browse latest Browse all 546

PowerShell Script to Distribute Scripting Agent Configuration File to Exchange Servers

$
0
0

One of the components of the Exchange Server scripting agent is the scripting agent config file itself.

This file, named ScriptingAgentConfig.xml, needs to exist on all of the Exchange servers in your organization if the scripting agent is enabled. Ideally you would also keep the file consistent across all of the servers as it gets updated with new actions.

Manual file copy is tedious. Scripting is the ideal approach to a problem like this, but the location where the file needs to be stored will vary depending on the install path for the Exchange Server application.

In a recent post I demonstrated using PowerShell to retrieve the install path of Exchange for remote servers. Extending on that I have written a script to handle the distribution of the scripting agent config file as well.

This script will:

  • Determine the install path of Exchange on the remote server, and use that to determine the path where the config file should be copied
  • Rename the existing ScriptingAgentConfig.xml file if it exists
  • Copy the new ScriptingAgentConfig.xml file from the same directory where the script is running to the remote server
  • Display a report so that success/failure can be identified

The script and config file just need to be located in the same folder. The script also requires the Exchange management tools to be installed, however it can be launched from regular PowerShell and will load the snapin automatically for you.

push-scripting-agent-config-script

Example output (the warning is caused by my Edge Transport server):

PS C:\Scripts\ScriptingAgentConfig> .\PushScriptingAgentConfig.ps1
WARNING: Exception calling "OpenRemoteBaseKey" with "2" argument(s): "Attempted to perform an unauthorized operation."
Server Name        : HO-EX2010-MB1
Config UNC Path    : \\HO-EX2010-MB1\C$\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents\Scripting
                     AgentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found
Server Name        : HO-EX2010-MB2
Config UNC Path    : \\HO-EX2010-MB2\C$\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents\Scripting
                     AgentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found
Server Name        : BR-EX2010-MB
Config UNC Path    : \\BR-EX2010-MB\C$\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents\ScriptingA
                     gentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found
Server Name        : HO-EX2010-PF
Config UNC Path    : \\HO-EX2010-PF\C$\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents\ScriptingA
                     gentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found
Server Name        : HO-EX2010-EDGE
Config UNC Path    : n/a
File Rename Result : n/a
File Copy Result   : n/a
File Check Result  : n/a

For more detailed output use the -Verbose parameter.

PS C:\Scripts\ScriptingAgentConfig> .\PushScriptingAgentConfig.ps1 -Verbose

Download the script file here: PushScriptingAgentConfig.ps1 (downloaded 1 times so far)

Feedback is welcome in the comments below.


This article PowerShell Script to Distribute Scripting Agent Configuration File to Exchange Servers is © 2014 ExchangeServerPro.com

Get more Exchange Server tips at ExchangeServerPro.com


Viewing all articles
Browse latest Browse all 546

Trending Articles