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:ScriptsScriptingAgentConfig> .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-MB1C$Program FilesMicrosoftExchange ServerV14BinCmdletExtensionAgentsScripting
                     AgentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found

Server Name        : HO-EX2010-MB2
Config UNC Path    : \HO-EX2010-MB2C$Program FilesMicrosoftExchange ServerV14BinCmdletExtensionAgentsScripting
                     AgentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found

Server Name        : BR-EX2010-MB
Config UNC Path    : \BR-EX2010-MBC$Program FilesMicrosoftExchange ServerV14BinCmdletExtensionAgentsScriptingA
                     gentConfig.xml
File Rename Result : Success
File Copy Result   : Success
File Check Result  : Found

Server Name        : HO-EX2010-PF
Config UNC Path    : \HO-EX2010-PFC$Program FilesMicrosoftExchange ServerV14BinCmdletExtensionAgentsScriptingA
                     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:ScriptsScriptingAgentConfig> .PushScriptingAgentConfig.ps1 -Verbose

Download the script file from Github

Feedback is welcome in the comments below.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. yacoob

    Using extension agents is a great thing, and your script is very helpful in distributing the customized ScriptingAgentConfig.xml file.
    But what if we have the full Exchange Online scenario? How (and where) can you place that XML file? Is it at all possible?
    Thanks in advance for any clues.

    yacoob

Leave a Reply