Exchange 2013 – How to change config xml files in PowerShell


Let me show you with few examples how can we modify Exchange config files (e.g. EdgeTransport.exe.config) in PowerShell.

Change value

For example change key AgentLogEnabled and its value: 02-05-2013 1-31-5402-05-2013 1-44-39

$EdgeTransportPath = "D:\Exchsrvr\Bin\EdgeTransport.exe.config"
[xml]$EdgeTransport = Get-Content -Path $EdgeTransportPath
($EdgeTransport.configuration.appSettings.add | Where key -Match "AgentLogEnabled").value = "False"
$EdgeTransport.Save($EdgeTransportPath)

Create element

$EdgeTransportPath = "D:\Exchsrvr\Bin\EdgeTransport.exe.config"
[xml]$EdgeTransport = Get-Content -Path $EdgeTransportPath
$element = $EdgeTransport.CreateElement('add')
$element.SetAttribute('key', 'AgentLogLevel')
$element.SetAttribute('value', 'Disabled')
$EdgeTransport.configuration.appSettings.AppendChild($element)
$EdgeTransport.Save($EdgeTransportPath)

02-05-2013 4-34-54Remove element

$EdgeTransportPath = "D:\Exchsrvr\Bin\EdgeTransport.exe.config"
[xml]$EdgeTransport = Get-Content -Path $EdgeTransportPath
$element = $EdgeTransport.configuration.appSettings.add | where key -like "AgentLogLevel"
($EdgeTransport.configuration.appSettings).RemoveChild($element)
$EdgeTransport.Save($EdgeTransportPath)

Other methods

ToString, AppendChild, Clone, CloneNode, CreateAttribute, CreateCDataSection, CreateComment, CreateDocumentFragment, CreateDocumentType, CreateElement, CreateEntityReference, CreateNavigator, CreateNode, CreateProcessingInstruction, CreateSignificantWhitespace, CreateTextNode, CreateWhitespace, CreateXmlDeclaration, Equals, GetElementById, GetElementsByTagName, GetEnumerator, GetHashCode, GetNamespaceOfPrefix, GetPrefixOfNamespace, GetType, ImportNode, InsertAfter, InsertBefore, Load, LoadXml, Normalize, PrependChild, ReadNode, RemoveAll, RemoveChild, ReplaceChild, Save, SelectNodes, SelectSingleNode, Supports, Validate, WriteContentTo, WriteTo

Exchange config files

EdgeTransport.exe.config, Microsoft.Exchange.AntispamUpdateSvc.exe.config, Microsoft.Exchange.Diagnostics.Service.exe.config, Microsoft.Exchange.Directory.TopologyService.exe.config, Microsoft.Exchange.EdgeSyncSvc.exe.config, Microsoft.Exchange.ProtectedServicehost.exe.config, Microsoft.Exchange.RpcClientAccess.Service.exe.config, Microsoft.Exchange.Search.Service.exe.config, Microsoft.Exchange.Servicehost.exe.config, Microsoft.Exchange.Store.Service.exe.config, Microsoft.Exchange.Store.Worker.exe.config, Microsoft.Exchange.TransportSyncManagerSvc.exe.config, mmc.exe.config, MSExchangeDelivery.exe.config, MSExchangeFrontEndTransport.exe.config, MSExchangeHMHost.exe.config, MSExchangeHMWorker.exe.config, MSExchangeMailboxAssistants.exe.config, MsExchangeMailboxReplication.exe.config, msexchangerepl.exe.config, MSExchangeSubmission.exe.config, MSExchangeThrottling.exe.config, MSExchangeTransport.exe.config, MSExchangeTransportLogSearch.exe.config, SetupUI.exe.config, UMservice.exe.config, UMWorkerProcess.exe.config

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s