Announcement

Collapse
No announcement yet.

Exchange 2013 powershell move log

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exchange 2013 powershell move log

    I have tried to change the AgentLog location with this .ps1 script

    [CODE]
    # ------------------------
    #
    # Version 1.0 by KSB
    #
    # This script will move all of the configurable logs for Exchange 2013 from the C: drive
    # to the D: drive. The folder subtree and paths on D: 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:ServerName
    #
    # Move the standard log files for the TransportService to the same path on the D: drive that they were on C:
    #
    Set-TransportService -Identity ServerName `
    # -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" `
    # -MessageTrackingLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" `
    # -IrmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" `
    # -ActiveUserStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStat s" `
    # -ServerStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" `
    # -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pReceive" `
    # -RoutingTableLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" `
    # -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pSend" `
    # -QueueLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" `
    # -WlmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" `
    # -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing " `
    -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"
    #
    # Move the path for the PERFMON logs from the C: drive to the D: drive
    #
    # logman -stop ExchangeDiagnosticsDailyPerformanceLog
    # logman -update ExchangeDiagnosticsDailyPerformanceLog -o "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\DailyPerformanceLog s\ExchangeDiagnosticsDailyPerformanceLog"
    # logman -start ExchangeDiagnosticsDailyPerformanceLog
    # logman -stop ExchangeDiagnosticsPerformanceLog
    # logman -update ExchangeDiagnosticsPerformanceLog -o "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\PerformanceLogsToBe Processed\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 "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\EdgeSync"
    #
    # Move the standard log files for the FrontEndTransportService to the same path on the D: drive that they were on C:
    #
    # Set-FrontendTransportService -Identity ServerName `
    # -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\AgentLog" `
    # -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivi ty" `
    # -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLo g\SmtpReceive" `
    # -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLo g\SmtpSend"
    #
    # Move the log path for the IMAP server
    #
    # Set-ImapSettings -LogFileLocation "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Imap4"
    #
    # Move the logs for the MailBoxServer
    #
    # Set-MailboxServer -Identity Exchange01.hilsoe.local `
    # -CalendarRepairLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Calendar Repair Assistant" `
    # -MigrationLogFilePath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Managed Folder Assistant"
    #
    # Move the standard log files for the MailboxTransportService to the same path on the D: drive that they were on C:
    #
    # Set-MailboxTransportService -Identity ServerName `
    # -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\Connectivit y" `
    # -MailboxDeliveryAgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\De livery" `
    # -MailboxSubmissionAgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Su bmission" `
    # -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog \SmtpReceive" `
    # -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog \SmtpSend" `
    # -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\PipelineTra cing"
    #
    # Move the log path for the POP3 server
    #
    # Set-PopSettings -LogFileLocation "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Pop3"
    [CODE]

    When I run the script I get this error

    WARNING: The command completed successfully but no settings of 'ServerName' have been modified.
    -AgentLogPath : The term '-AgentLogPath' is not recognized as the name of a cmdlet, function, script file, or operable
    program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At X:\Scripts\MoveEX2013logs.ps1:26 char:1
    + -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Log ...
    + ~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (-AgentLogPath:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


  • #2
    Don't know about the individual commands and how they'll perform, but the most apparent thing I see is that virtually every line in your code is commented out. Any line that begins with the '#' character is ignored as a comment line. Since you only have a couple of lines that aren't commented out, those are the only ones which are even attempting to execute. Your first action line is the 'Set-TransportService -Identity...' line, but your command line wraps (`) are ignored because every line after that begins with '#', until you get to the 'AgentLogPath...' line, which is where your code stops.

    Try this, Copy/paste into Powershell ISE and be sure to make each command 1 line--text editing puts some line wraps in which you don't want:
    # ------------------------

    # Version 1.0 by KSB

    # This script will move all of the configurable logs for Exchange 2013 from the C: drive
    # to the D: drive. The folder subtree and paths on D: 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:ServerName

    # Move the standard log files for the TransportService to the same path on the D: drive that they were on C:

    Set-TransportService -Identity ServerName `
    -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" `
    -MessageTrackingLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" `
    -IrmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" `
    -ActiveUserStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStat s" `
    -ServerStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" `
    -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pReceive" `
    -RoutingTableLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" `
    -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pSend" `
    -QueueLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" `
    -WlmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" `
    -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing " `
    -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"

    # Move the path for the PERFMON logs from the C: drive to the D: drive

    logman -stop ExchangeDiagnosticsDailyPerformanceLog
    logman -update ExchangeDiagnosticsDailyPerformanceLog -o "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostic\DailyPerformanceLogs \ExchangeDiagnosticsDailyPerformanceLog"
    logman -start ExchangeDiagnosticsDailyPerformanceLog
    logman -stop ExchangeDiagnosticsPerformanceLog
    logman -update ExchangeDiagnosticsPerformanceLog -o "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\PerformanceLogsToBe Processed\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 "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\EdgeSync"

    # Move the standard log files for the FrontEndTransportService to the same path on the D: drive that they were on C:

    Set-FrontendTransportService -Identity ServerName `
    -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\AgentLog" `
    -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\Connectivi ty" `
    -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLo g\SmtpReceive" `
    -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\FrontEnd\ProtocolLo g\SmtpSend"

    # Move the log path for the IMAP server

    Set-ImapSettings -LogFileLocation "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Imap4"

    # Move the logs for the MailBoxServer

    Set-MailboxServer -Identity Exchange01.hilsoe.local `
    -CalendarRepairLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Calendar Repair Assistant" `
    -MigrationLogFilePath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Managed Folder Assistant"

    # Move the standard log files for the MailboxTransportService to the same path on the D: drive that they were on C:

    Set-MailboxTransportService -Identity ServerName `
    -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\Connectivit y" `
    -MailboxDeliveryAgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\De livery" `
    -MailboxSubmissionAgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\AgentLog\Su bmission" `
    -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog \SmtpReceive" `
    -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\ProtocolLog \SmtpSend" `
    -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Mailbox\PipelineTra cing"

    # Move the log path for the POP3 server

    Set-PopSettings -LogFileLocation "D:\Program Files\Microsoft\Exchange Server\V15\Logging\Pop3"

    Good Luck!
    *RicklesP*
    MSCA (2003/XP), Security+, CCNA

    ** Remember: credit where credit is due, and reputation points as appropriate **

    Comment


    • #3
      I am aware of # commenting out lines that begins with it. The only log I am trying to ude another location AgentLog.

      Comment


      • #4
        If you're only trying to move 1 log, put that statement on the line immediately after the 'set-...' line so there's no comment-out between the command and the active subcommand you want to run. You could probably delete the unnecessary lines after that, rather than commenting them out, but any active components should be read in a direct sequence, one after the other, without other components commented out in between.
        *RicklesP*
        MSCA (2003/XP), Security+, CCNA

        ** Remember: credit where credit is due, and reputation points as appropriate **

        Comment


        • #5
          You can continue a line on the next line by using the back tick ( ` ) like the script does. But commenting out all the commands also commented out the back ticks.

          Without comments, powershell would read it like this:
          Code:
          ...
          Set-TransportService -Identity ServerName -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" -MessageTrackingLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" -IrmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" -ActiveUserStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStat s" -ServerStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pReceive" -RoutingTableLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pSend" -QueueLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" -WlmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing " -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"
          ...
          With the comments it now reads like this:

          Code:
          Set-TransportService -Identity ServerName # -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" `
          # -MessageTrackingLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" `
          # -IrmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" `
          # -ActiveUserStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStat s" `
          # -ServerStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" `
          # -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pReceive" `
          # -RoutingTableLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" `
          # -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pSend" `
          # -QueueLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" `
          # -WlmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" `
          # -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing " `
          -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"
          So for your situation, simply remove the commented out lines (as suggested) and delete the blank lines or move the AgentLogPath parameter up like this:
          Code:
          ...
          Set-TransportService -Identity ServerName `
          -AgentLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog"
          # -ConnectivityLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity" `
          # -MessageTrackingLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking" `
          # -IrmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs" `
          # -ActiveUserStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStat s" `
          # -ServerStatisticsLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats" `
          # -ReceiveProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pReceive" `
          # -RoutingTableLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing" `
          # -SendProtocolLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\Smt pSend" `
          # -QueueLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer" `
          # -WlmLogPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\WLM" `
          # -PipelineTracingPath "D:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing " `
          ...
          More info on the back tick:
          http://powershell.org/wp/2013/07/10/...ate-backticks/
          http://www.computerperformance.co.uk...l_backtick.htm
          Regards,
          Jeremy

          Network Consultant/Engineer
          Baltimore - Washington area and beyond
          www.gma-cpa.com

          Comment


          • #6
            Points taken. I have solved the problem taking the things I needed and made one script line instead of using the whole script file.

            Comment

            Working...
            X