How to export and filter All Available MailboxDiagnosticLogs

Exchange offer us access to Mailbox Diagnostic Logs so in case of issues we know what happened with many components. The cmdlet is available both in Exchange and Exchange Online but some parameter's values might differ. Here I'll focus only on Exchange Online.

You can find official documentation about Export-MailboxDiagnosticLogs on TechNet.

I noticed that many administrators don't know which are the Component Names for which they can export mailbox diagnostic logs (the documentation is not always updated).

Currently the diagnostic logs for following components are available:
- AttendeeListReplicationAssistant
- InternetCalendar
- CalendarSharingLocalFolder
- ActionProcessingAgent
- FreeBusyPublishingAssistantQuickLog
- SharingMigrationAssistant
- ClearCalendar
- OOFRules
- DefaultViewIndexer
- DelegateRulesManagement
- BirthdayAssistant
- MeetingMessageProcessingAgent
- RemindersAssistant
- Calendar
- CalendarPermissions
- SharingPermissionManagement
- SharingSyncAssistant
- HoldTracking

Also, when exporting ExtendedProperties the result is an XML that is hard to digest.

For this reasons I've created a script who will check every time which are the available components for which you can get logs and you can also choose what you want to export (either one component or all).

You can also view & sort the ExtendedProperties with their values and this data will be exported as well.

The script allow you to see the results in the Console & GridView but also exports MailboxDiagnosticLogs for the selected component (or for all) and all extended properties.

Script Requirements:
- to be a Global Admin
- to have at least PowerShell version 3 installed (you can use "Get-Host" to check it)

How to run the script:
1. run Get-MailboxDiagnosticLogs.ps1
2. provide Global Admin credentials
3. Provide PATH where the outputs will be exported
4. Provide the mailbox for which the MailboxDiagnosticLogs will be shown and exported

You can download the script from the following location:TechNet Gallery #region Disclaimer Write-Host " Note: Before you run the script: The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages. " -ForegroundColor Red #endregion #region Current values for Component Names #endregion #region Connect to Exchange Online Write-Host "`nPlease input your credential in the logging window!" -ForegroundColor Green $LiveCred = Get-Credential $Error.Clear() $previousErrorActionPreference = $global:ErrorActionPreference $global:ErrorActionPreference = 'Stop' Try { $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $LiveCred -Authentication Basic -AllowRedirection Import-PSSession $O365Session -AllowClobber } Catch { Try { $proxysettings = New-PSSessionOption -ProxyAccessType IEConfig $O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $LiveCred -Authentication Basic -AllowRedirection -SessionOption $proxysettings Import-PSSession $O365Session -AllowClobber } Catch{ Write-Host "`nWe couldn't connect with or without proxy to Exchange Online! Press [Enter] to exit" -ForegroundColor Red Read-Host $global:ErrorActionPreference = $previousErrorActionPreference Exit } } $global:ErrorActionPreference = $previousErrorActionPreference # removing limit of showing only 4 values for one property (only in current session) $FormatEnumerationLimit = -1 # get a timestamp $Ts= get-date -Format yyyyMMdd_HHmmss Write-Host "`nPlease input the path were the files will be saved" -ForegroundColor Green $ExportPath = Read-Host if ($ExportPath[-1] -eq "\") { $ExportPath = $ExportPath.Substring(0,$ExportPath.Length-1) } If (Test-Path -Path $ExportPath) { #Write-Host "`nThe path exist!" -ForegroundColor Green } else { Write-Host "`nThe output folder doesn't exist or is not valid! Please create or use an existing one and re-run the script. Press [Enter] to exit" -ForegroundColor Red Read-Host Exit } #endregion #region MbxDiagLogs Write-Host "`nPlease input the mailbox for which you want to see MailboxDiagnosticLogs: " -ForegroundColor Green $mbx = Read-Host # Check if mailbox exist $previousErrorActionPreference = $global:ErrorActionPreference $global:ErrorActionPreference = 'Stop' try{ Get-Mailbox $mbx | Out-Null } Catch{ Write-Host "`nThe mailbox $mbx doesn't exist. Press [Enter] to exit" Read-Host $ErrorActionPreference = $previousErrorActionPreference Exit } $global:ErrorActionPreference = $previousErrorActionPreference # Getting available components that can be exported $previousErrorActionPreference = $global:ErrorActionPreference $global:ErrorActionPreference = 'Stop' Try { Export-MailboxDiagnosticLogs $mbx -ComponentName TEST } Catch { Write-Host "in catch" $MbxDiagLogs = ((($error[0].Exception.Message -Split "Available logs: ")[1] -replace "'") -split ",") -replace " " } $global:ErrorActionPreference = $previousErrorActionPreference Write-Host "`nPlease type (1) if you want the logs for Primary mailbox or (2) if you want to see the logs for the Archive? (for a different answer will show directly the Primary Mailbox)" -ForegroundColor Green $answer = Read-Host If ($answer -eq 2 ) {$ArchiveSwitch = $true} else { $ArchiveSwitch = $False } # Export-MailboxDiagnosticLogs with ComponentName $option = ( $MbxDiagLogs + "ALL")|Out-GridView -PassThru -Title "Choose a specific ComponentName or the last one for ALL" if ($option -ne "ALL") { Write-Host "`nGetting $option logs" -ForegroundColor Yellow Export-MailboxDiagnosticLogs $mbx -ComponentName $option -Archive:$ArchiveSwitch| Tee-Object $ExportPath\$($Ts)_$option.txt } else { $MbxDiagLogs |%{ Write-Host "`nGetting $_ logs" -ForegroundColor Yellow Export-MailboxDiagnosticLogs $mbx -ComponentName $_ -Archive:$ArchiveSwitch| Tee-Object $ExportPath\$($Ts)_$_.txt } } # Export-MailboxDiagnosticLogs with ExtendedProperties Write-Host "You can view & filter ExtendedProperties in the Grid View window." -ForegroundColor Yellow $extendLogs = Export-MailboxDiagnosticLogs $mbx -ExtendedProperties $ExtendedProps = [XML]$extendLogs.MailboxLog $ExtendedProps.Properties.MailboxTable.Property | Select name,value | Out-GridView -Title "All ExtendedProperties with values (you can filter here to find what is interesting for you; e.g: use `"ELC`" for MRM properties)" $ExtendedProps.Properties.MailboxTable.Property | Select name,value |Out-File $ExportPath\$($Ts)_ExtendedProperties.txt Write-Host "`nOutput was exported in the following location: $ExportPath" -ForegroundColor Yellow # Cleaning created PSSesion Remove-PSSession $O365Session #endregion