Script: Set-TransportLogs.ps1


Starting with Exchange 2013 there are now three groups of transport related logs: Front-End (new to 2013), Back-End (or just Transport), and Mailbox Transport. By default, these logs all go under the directory where you install Exchange, which is the C: (system drive) by default. I’ve seen these logs easily take up GBs of space since they are saved for 30 days, by default, and generate many lines in multiple logs for each message transmitted.

So I created this script to easily reconfiguration the location of these logs to save space on the install drive and make troubleshooting\finding these logs easier. I also enable NTFS compression on my D:\Logs directory to further save space. In my environment I have two Exchange 2013 servers, three Exchange 2016 servers, and two EDGE 2016 servers. This script will exclude any server with the name “EDGE” in it, since normally the EDGE servers are in the DMZ and can’t be accessed from the internal network and some transport cmdlets can’t be run against an EDGE server directly.

This script will not move the old or currently opened log files, so you will need to some some manually clean-up.

Set-TransportLogs.ps1

$FEReceivePath = "D:\Logs\Transport\FE\Receive"
$FESendPath = "D:\Logs\Transport\FE\Send"
$FEConnectivityLogPath  = "D:\Logs\Transport\FE\Connectivity"

$BEReceivePath = "D:\Logs\Transport\BE\Receive"
$BESendPath = "D:\Logs\Transport\BE\Send"
$BEConnectivityLogPath  = "D:\Logs\Transport\BE\Connectivity"

$MBXReceivePath = "D:\Logs\Transport\MBX\Receive"
$MBXSendPath = "D:\Logs\Transport\MBX\Send"
$MBXConnectivityLogPath = "D:\Logs\Transport\MBX\Connectivity" 

$Servers = Get-TransportService | ? {$_.Name -NotLike "*EDGE*"}

ForEach ($Server in $Servers) {
	$ServerName = $($Server).Name
	Write-Host "Setting Log Paths on [$ServerName]"
	Set-FrontendTransportService $ServerName -ReceiveProtocolLogPath $FEReceivePath -SendProtocolLogPath $FESendPath -ConnectivityLogPath $FEConnectivityLogPath -ConnectivityLogEnabled $True
	Set-TransportService $ServerName -ReceiveProtocolLogPath $BEReceivePath -SendProtocolLogPath $BESendPath -ConnectivityLogPath $BEConnectivityLogPath -ConnectivityLogEnabled $True
	Set-MailboxTransportService $ServerName -ConnectivityLogPath $MBXConnectivityLogPath -ReceiveProtocolLogPath $MBXReceivePath -SendProtocolLogPath $MBXSendPath
}

Write-Host "`nFrontendTransportService:"
Get-FrontendTransportService | ? {$_.Name -NotLike "*EDGE*"} | FT Name, ReceiveProtocolLogPath, SendProtocolLogPath, ConnectivityLogPath -Wrap
Write-Host "TransportService:"
Get-TransportService | ? {$_.Name -NotLike "*EDGE*"} | FT Name, ReceiveProtocolLogPath, SendProtocolLogPath, ConnectivityLogPath -Wrap
Write-Host "MailboxTransportService:"
Get-MailboxTransportService | FT Name, *Protocollogpath*, ConnectivityLogPath -Wrap

About Jason Sherry

I am a ~30 year Exchange consultant and expert. I currently work for Commvault as a Solutions Specialist for Microsoft Infrastructure For more info see my resume at: http://resume.jasonsherry.org
This entry was posted in Exchange, Script, Technical and tagged , . Bookmark the permalink.

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 )

Facebook photo

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

Connecting to %s