Introduction

Exchange 2013 has drastically increased the amount of logging that happens by default.   So much so that the suggested free space for the install of 2013 on the C: drive is now up to 30 GB.    Much of this space is due to the size of the log files.      In the past the best practices for installing exchange were to move logging onto its own partition (or even better) its own drive.    With the introduction of 2013, this is a tedious task because of the number of logs involved with each of the roles.

Problem

Problem with the current default configuration is that it is wasteful and creates several issues that an administrator must deal with:

  • Placing log files that constantly grow and recreate themselves on the same partition as the OS creates fragmentation
  • Having 30GB or more of extra space may require us to purchase larger disks for our OS volume.  For example, I always use SSD drives for the OS volume.  I don't want to pay for log files to sit on expensive SSD storage.
  • Backup requirements for my OS volume are not the same as my requirements for less critical data like log files.   I may want to backup the OS volume daily and log files less often or not at all.  Having them on the same volume makes the configuration of the backup job more complicated.
  • Increasing the longevity of the log files can easily consume even well planned volumes.
Unfortunately, I can only find a way to move about 1/3 of the log files that exchange creates.   The other 2/3 seem to be unconfigurable.  I would welcome anyone to edit this WIKI or commend if they can find a way to move more of the logs.

Solution

While we can move a few of the log files with the GUIs, it is probably better just to do them all at once using Powershell.  I usually create a volume for my log files and label it as drive L:.  So in my scripts, we will see everything is going to be moved to the same folder tree it originally resided on but in a different drive.  I will say without hesitation that i am not an expert in PowerShell.   My script is very basic and I am sure that someone more skilled in PS would be able to spruce it up by inserting more variables or other bits of fancy code.   This script does not move the existing log files to a new location.  It only moves future log files.   Existing log files are left alone.

 Caution
The writer cannot be helpd resposible for any different output from the script  Use it at your OWN RISK. If you are not aware with logic of code dont use it please..

# ------------------------
# MoveEX2013logs.ps1
# ------------------------
#
# Version 1.0 by KSB
#
# 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" `
-MessageTrackingLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" `
-IrmLogPath "L:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" `
-ActiveUserStatisticsLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats" `
-ServerStatisticsLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" `
-ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive" `
-RoutingTableLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" `
-SendProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend" `
-QueueLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" `
-WlmLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" `
-PipelineTracingPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing" `
-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" `
-ConnectivityLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivity" `
-ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive" `
-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" `
-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" `
-MailboxDeliveryAgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Delivery" `
-MailboxSubmissionAgentLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Submission" `
-ReceiveProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive" `
-SendProtocolLogPath "L:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend" `
-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"

Once we have completed moving the logs as shown above,  would recommend we restart the server. 

If we had the server running for a while with the default logging locations and we want to clean up the old log files that we just redirected then we can run the script below to remove the old folders and files from the C: drive and reclaim some of our free space.  

 Caution
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.

 

# ------------------------
# 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

Final Thoughts

Hopefully in the future Microsoft will have a change of heart and provide us with a way to move the other 2/3 of the log files created by Exchange 2013.   It would also be nice if they gave us a choice during the installation to select a drive for logging.   Please feel free to update this wiki with a better script if we are a PowerShell expert or with more commands if we can find a way to move more of the logging.  

I also have a script to change the default logging time from 30 days to 90 days.  I will make a different WIKI for that so as not to confuse topics.

Below is a script I modified based upon the original move log paths script above.  Not sure how to post script code, so the formatting may be off a little. - ALM

<#
---------------------------------------------
Exchange2013-MoveLoggingPaths.ps1
---------------------------------------------
Version 1.0 by KSB
Version 1.1 by ALM
This script will move all of the configurable logs for Exchange 2013 from the C: drive
to a new path. The folder subtree and paths on L: will stay the same as they were on C:
ALM:
- Changed script file name to correspond with my naming convention
- Added variable for new base log file path
- Updated comments
- Added code to move existing Log files to new path
- Added changes recommended in the original post comments section
- Added IIS log files move
- Added logic to Move Transport DB - Mail.que location (if desired)
- Added a few more log paths
#>
# Get the name of the local computer and set it to a variable for use later on.
$ExchangeServerName = $env:COMPUTERNAME
# Set base paths for log files locations
$NewLogPath = "E:\Exchange\LogFiles" # "L:\Program Files\Microsoft\Exchange Server\V15"
$OldLogPath = $env:ExchangeInstallPath # "C:\Program Files\Microsoft\Exchange Server\V15"
$NewIISLogPath = "E:\IIS\LogFiles"
$OldIISLogPath = $env:SystemDrive\inetpub\logs\LogFiles
# IF set $MoveQue = $true then move location of Transport DB (mail.que)
$MoveQue = $false
IF ($MoveQue) {
$EXScripts = "$OldLogPath\Scripts"
CD $EXScripts
$ExchTDBPath = "J:\Exchange\TransportRoles\data"
.\Move-TransportDatabase.ps1 -queueDatabasePath "$ExchTDBPath\Queue" -queueDatabaseLoggingPath "$ExchTDBPath\Queue" -iPFilterDatabasePath "$ExchTDBPath\IpFilter" -iPFilterDatabaseLoggingPath "$ExchTDBPath\IpFilter" -temporaryStoragePath "$ExchTDBPath\Temp"
}
#Define logging subfolders
$ExchLogPaths = @("Logging\Calendar Repair Assistant")
$ExchLogPaths += "Logging\Diagnostics\AnalyzerLogs"
$ExchLogPaths += "Logging\Diagnostics\CertificateLogs"
$ExchLogPaths += "Logging\Diagnostics\CosmosLog"
$ExchLogPaths += "Logging\Diagnostics\DailyPerformanceLogs"
$ExchLogPaths += "Logging\Diagnostics\Dumps"
$ExchLogPaths += "Logging\Diagnostics\EtwTraces"
$ExchLogPaths += "Logging\Diagnostics\PerformanceLogsToBeProcessed"
$ExchLogPaths += "Logging\Diagnostics\Poison"
$ExchLogPaths += "Logging\Diagnostics\ServiceLogs"
$ExchLogPaths += "Logging\Diagnostics\Store"
$ExchLogPaths += "Logging\Diagnostics\TraceArchive"
$ExchLogPaths += "Logging\Diagnostics\Watermarks"
$ExchLogPaths += "Logging\Imap4"
$ExchLogPaths += "Logging\IRMLogs"
$ExchLogPaths += "Logging\Managed Folder Assistant"
$ExchLogPaths += "Logging\MigrationLogs"
$ExchLogPaths += "Logging\Pop3"
$ExchLogPaths += "TransportRoles\Logs\EdgeSync"
$ExchLogPaths += "TransportRoles\Logs\FrontEnd\AgentLog"
$ExchLogPaths += "TransportRoles\Logs\FrontEnd\Connectivity"
$ExchLogPaths += "TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive"
$ExchLogPaths += "TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpSend"
$ExchLogPaths += "TransportRoles\Logs\Hub\ActiveUsersStats"
$ExchLogPaths += "TransportRoles\Logs\Hub\AgentLog"
$ExchLogPaths += "TransportRoles\Logs\Hub\Connectivity"
$ExchLogPaths += "TransportRoles\Logs\Hub\PipelineTracing"
$ExchLogPaths += "TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive"
$ExchLogPaths += "TransportRoles\Logs\Hub\ProtocolLog\SmtpSend"
$ExchLogPaths += "TransportRoles\Logs\Hub\QueueViewer"
$ExchLogPaths += "TransportRoles\Logs\Hub\Routing"
$ExchLogPaths += "TransportRoles\Logs\Hub\ServerStats"
$ExchLogPaths += "TransportRoles\Logs\Hub\WLM"
$ExchLogPaths += "TransportRoles\Logs\JournalLog"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\AgentLog\Delivery"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\AgentLog\Submission"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\Connectivity"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\PipelineTracing"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive"
$ExchLogPaths += "TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend"
$ExchLogPaths += "TransportRoles\Logs\MessageTracking"
$ExchLogPaths += "TransportRoles\Pickup"
$ExchLogPaths += "TransportRoles\Replay"
$IISLogPaths = @("W3SVC1")
$IISLogPaths += "W3SVC2"
# Create new log folders
FOREACH ($ExchLogPath in $ExchLogPaths) {
New-Item -Path $NewLogPath -Name $ExchLogPath -ItemType "Directory"
}
FOREACH ($IISLogPath in $IISLogPaths) {
New-Item -Path $NewLogPath -Name "$NewIISLogPath\$IISLogPath" -ItemType "Directory"
}
# Pre Move Existing log files from old path to new path - To save time moving while Services are stopped.  If folder doesn't exist then move will fail.
FOREACH ($ExchLogPath in $ExchLogPaths) {
Get-ChildItem -Path "$OldLogPath\$ExchLogPath\*" | Move-Item -Destination "$NewLogPath\$ExchLogPath"
}
FOREACH ($IISLogPath in $IISLogPaths) {
Get-ChildItem -Path "$env:SystemDrive\inetpub\logs\LogFiles\$IISLogPath\*" | Move-Item -Destination "$NewLogPath\IIS\$IISLogPath"
}
# Stop All MS Exchange Services
Get-Service -Name “MSExchange*” | ?{$_.Status -eq 'Running'} | Stop-Service -Force
# Move the path for the PERFMON logs from the C: drive to the new path
REG ADD HKLM\SOFTWARE\Microsoft\ExchangeServer\v15\Diagnostics /v LogFolderPath /t REG_SZ /d "$NewLogPath\Logging\Diagnostics"
<# ORIGINAL CODE TO MOVE PERFMON LOGGING
logman -stop ExchangeDiagnosticsDailyPerformanceLog
logman -update ExchangeDiagnosticsDailyPerformanceLog -o "$NewLogPath\Logging\Diagnostics\DailyPerformanceLogs\ExchangeDiagnosticsDailyPerformanceLog"
logman -start ExchangeDiagnosticsDailyPerformanceLog
logman -stop ExchangeDiagnosticsPerformanceLog
logman -update ExchangeDiagnosticsPerformanceLog -o "$NewLogPath\Logging\Diagnostics\PerformanceLogsToBeProcessed\ExchangeDiagnosticsPerformanceLog"
logman -start ExchangeDiagnosticsPerformanceLog
#>
# Move the standard log files for the TransportService to new path
Set-TransportService -Identity $ExchangeServerName `
-ConnectivityLogPath "$NewLogPath\TransportRoles\Logs\Hub\Connectivity" `
-MessageTrackingLogPath "$NewLogPath\TransportRoles\Logs\MessageTracking" `
-IrmLogPath "$NewLogPath\Logging\IRMLogs" `
-ActiveUserStatisticsLogPath "$NewLogPath\TransportRoles\Logs\Hub\ActiveUsersStats" `
-ServerStatisticsLogPath "$NewLogPath\TransportRoles\Logs\Hub\ServerStats" `
-ReceiveProtocolLogPath "$NewLogPath\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive" `
-RoutingTableLogPath "$NewLogPath\TransportRoles\Logs\Hub\Routing" `
-SendProtocolLogPath "$NewLogPath\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend" `
-QueueLogPath "$NewLogPath\TransportRoles\Logs\Hub\QueueViewer" `
-WlmLogPath "$NewLogPath\TransportRoles\Logs\Hub\WLM" `
-PipelineTracingPath "$NewLogPath\TransportRoles\Logs\Hub\PipelineTracing" `
-AgentLogPath "$NewLogPath\TransportRoles\Logs\Hub\AgentLog" `
-PickupDirectoryPath "$NewLogPath\TransportRoles\Pickup" `
-ReplayDirectoryPath "$NewLogPath\TransportRoles\Replay" `
-JournalLogPath "$NewLogPath\TransportRoles\Logs\JournalLog"
# 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 "$NewLogPath\TransportRoles\Logs\EdgeSync"
# Move the standard log files for the FrontEndTransportService to the new path
Set-FrontendTransportService -Identity $ExchangeServerName `
-AgentLogPath "$NewLogPath\TransportRoles\Logs\FrontEnd\AgentLog" `
-ConnectivityLogPath "$NewLogPath\TransportRoles\Logs\FrontEnd\Connectivity" `
-ReceiveProtocolLogPath "$NewLogPath\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpReceive" `
-SendProtocolLogPath "$NewLogPath\TransportRoles\Logs\FrontEnd\ProtocolLog\SmtpSend" `
# Move the log path for the IMAP server
Set-ImapSettings -LogFileLocation "$NewLogPath\Logging\Imap4"
# Move the logs for the MailBoxServer
Set-MailboxServer -Identity $ExchangeServerName `
-CalendarRepairLogPath "$NewLogPath\Logging\Calendar Repair Assistant" `
-MigrationLogFilePath "$NewLogPath\Logging\MigrationLogs" `
-LogPathForManagedFolders "$NewLogPath\Logging\Managed Folder Assistant"
# Move the standard log files for the MailboxTransportService to the same path on the new path
Set-MailboxTransportService -Identity $ExchangeServerName `
-ConnectivityLogPath "$NewLogPath\TransportRoles\Logs\Mailbox\Connectivity" `
-MailboxDeliveryAgentLogPath "$NewLogPath\TransportRoles\Logs\Mailbox\AgentLog\Delivery" `
-MailboxSubmissionAgentLogPath "$NewLogPath\TransportRoles\Logs\Mailbox\AgentLog\Submission" `
-ReceiveProtocolLogPath "$NewLogPath\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpReceive" `
-SendProtocolLogPath "$NewLogPath\TransportRoles\Logs\Mailbox\ProtocolLog\SmtpSend" `
-PipelineTracingPath "$NewLogPath\TransportRoles\Logs\Mailbox\PipelineTracing"
# Move the log path for the POP3 server
Set-PopSettings -LogFileLocation "$NewLogPath\Logging\Pop3"
# Stop IIS Services
Stop-Service "W3C Logging Service"
Stop-Service "World Wide Web Publishing Service"
# Move IIS Log Files for existing websites !!! NOTE !!! WILL NOT MOVE DEFAULT LOCATION FOR NEW SITES AFTER THIS IS RUN !!!
Import-Module WebAdministration
Get-WebSite | FOREACH {Set-ItemProperty "IIS:\Sites\$($_.name)" -name logFile.directory -value "$NewLogPath\IIS"}
# Move Remaining Existing log files from old path to new path
FOREACH ($ExchLogPath in $ExchLogPaths) {
Get-ChildItem -Path "$OldLogPath\$ExchLogPath\*" | Move-Item -Destination "$NewLogPath\$ExchLogPath"
}
FOREACH ($IISLogPath in $IISLogPaths) {
Get-ChildItem -Path "$OldIISLogPath\$IISLogPath\*" | Move-Item -Destination "$NewIISLogPath\$IISLogPath"
}
# Restart Services
Get-Service -Name “MSExchange*” | ?{$_.Status -eq 'Stopped' -and $_.StartType -eq 'Automatic'} | Start-Service
Start-Service "World Wide Web Publishing Service"
Start-Service "W3C Logging Service"