#Exchange2013 Aufräumarbeiten, #Protokolle verschieben

Himmel! Ein Default, alles an Protokollierung auf der Systemplatte zu lassen, finde ich (mit Verlaub) suboptimal. Exchange schleudert mal eben 60GB an Logs auf die Platte, u.a. liegt das auch an der neuen „Gesundheitsüberwachung“. Naja. Im Netz finde ich recht wenig dazu, immerhin dieses Ding hier und denke, es könnte Euch helfen.

Karl Bystrak schreibt im Technet Forum so ziemlich alle Pfade zusammen, die Exchange so für die Protokollierung nutzt und die man mit Powershell verschieben kann. Das Script lässt sich so jedoch nicht so nutzen, da er ähnlich faul schreibt, wie ich. Da sind dann Absatzfehler drin, die er im Set-Kommando unverträglich für Copy & Paste eingebaut hat. In sofern erst einmal die Routine in Copy & Paste- freundlicher Form, um die Protokolle von A nach B (in diesem Fall Laufwerk L:) zu verschieben:

# ------------------------ 
# MoveEX2013logs.ps1 
# ------------------------ 
# 
# Version 1.1 by KSB, angepasst von Joe 
# 
# This script will move all of the configurable logs for  Exchange 2013 from the C: drive 
# to the L: drive.  The folder subtree and  paths on L: will stay the same as they were on C: 
# 
# Get the name of the local computer and  set it to a variable for use later on. 
$exchangeservername = $env:computername 
# Move the standard log files for  the TransportService to the same path on the L: drive that they were on C:  
Set-TransportService -Identity $exchangeservername -ConnectivityLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity"
Set-TransportService -Identity $exchangeservername -MessageTrackingLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking"
Set-TransportService -Identity $exchangeservername -IrmLogPath "L:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs"
Set-TransportService -Identity $exchangeservername -ActiveUserStatisticsLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats"
Set-TransportService -Identity $exchangeservername -ServerStatisticsLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats"
Set-TransportService -Identity $exchangeservername -ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive"
Set-TransportService -Identity $exchangeservername -RoutingTableLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing"
Set-TransportService -Identity $exchangeservername -SendProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend"
Set-TransportService -Identity $exchangeservername -QueueLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer"
Set-TransportService -Identity $exchangeservername -WlmLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM"
Set-TransportService -Identity $exchangeservername -PipelineTracingPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing"
Set-TransportService -Identity $exchangeservername -AgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"
# move the path for  the PERFMON logs from the C: drive to the L: drive 
logman -stop ExchangeDiagnosticsDailyPerformanceLog 
logman -update ExchangeDiagnosticsDailyPerformanceLog -o "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\DailyPerformanceLogs\ExchangeDiagnosticsDailyPerformanceLog"
logman -start ExchangeDiagnosticsDailyPerformanceLog 
logman -stop ExchangeDiagnosticsPerformanceLog 
logman -update ExchangeDiagnosticsPerformanceLog -o "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\PerformanceLogsToBeProcessed\ExchangeDiagnosticsPerformanceLog"
logman -start ExchangeDiagnosticsPerformanceLog 
# Get the details on the EdgeSyncServiceConfig and  store them in a variable for use in setting the path 
$EdgeSyncServiceConfigVAR=Get-EdgeSyncServiceConfig 
# Move the Log Path using the variable we got 
Set-EdgeSyncServiceConfig -Identity $EdgeSyncServiceConfigVAR.Identity -LogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\EdgeSync"
# Move the standard log files for  the FrontEndTransportService to the same path on the L: drive that they were on C: 
Set-FrontendTransportService -Identity $exchangeservername -AgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\AgentLog"
Set-FrontendTransportService -Identity $exchangeservername -ConnectivityLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivity"
Set-FrontendTransportService -Identity $exchangeservername -ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive"
Set-FrontendTransportService -Identity $exchangeservername -SendProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpSend"
# MOve the log path for  the IMAP server 
Set-ImapSettings -LogFileLocation "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Imap4"
# Move the logs for  the MailBoxServer 
Set-MailboxServer -Identity $exchangeservername -CalendarRepairLogPath "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Calendar Repair Assistant"
Set-MailboxServer -Identity $exchangeservername -MigrationLogFilePath  "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Managed Folder Assistant"
# Move the standard log files for  the MailboxTransportService to the same path on the L: drive that they were on C: 
Set-MailboxTransportService -Identity $exchangeservername -ConnectivityLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\Connectivity"
Set-MailboxTransportService -Identity $exchangeservername -MailboxDeliveryAgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Delivery"
Set-MailboxTransportService -Identity $exchangeservername -MailboxSubmissionAgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Submission"
Set-MailboxTransportService -Identity $exchangeservername -ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive"
Set-MailboxTransportService -Identity $exchangeservername -SendProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend"
Set-MailboxTransportService -Identity $exchangeservername -PipelineTracingPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\PipelineTracing"
# Move the log path for  the POP3 server 
Set-PopSettings -LogFileLocation "L:\Program Files\Microsoft\Exchange Server\V15\Logging\Pop3"

Anschließend solltet Ihr überprüfen, ob die Protokollierung so, wie gehabt funktioniert und könnt die alten Protokolle wegräumen. KSB schreibt dazu jedoch:

BELOW SCRIPT DELETES FILES!!! I am not responsible if you damage your server with my scripts.  Use them at your OWN RISK.  If you don’t understand what they are doing, DO NOT USE THEM.

Und ich würde diese Warnung ernst nehmen. Also, prüft doppelt, bevor Ihr loslegt:

# ------------------------
# RemoveEX2013logs.ps1
# ------------------------
#
# Version 1.0 by KSB
#
# This script will delete the folders and files for the log files that have been redirected away from C:
# This will not work unless you have rebooted the server after moving the log files already.
#
# Delete the old log files that we just moved
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\EdgeSync" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\AgentLog" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivity" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpSend" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Imap4" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Calendar Repair Assistant" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Managed Folder Assistant" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\Connectivity" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Delivery" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Submission" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\PipelineTracing" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Pop3" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\DailyPerformanceLogs\" -force -rec
rmdir -path "C:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\PerformanceLogsToBeProcessed\" -force -rec

Anwendung wie immer auf eigene Gefahr. Für DAG’s müsst Ihr es etwas für Euch anpassen.
Quelle und weitere Informationen: Technet Wiki, LINK