Troubleshooting Mailbox and Database Statistics Data Collection

Troubleshooting Mailbox and Database Statistics Data Collection

In an Exchange Server monitor added in PowerShell mode, if performance metrics are visible but Mailbox and Database Statistics data is not collected, the issue might be that the normal PowerShell session is working fine, but the Exchange PS Session is not established. Follow the steps below to troubleshoot this.

1. Prerequisites:

  1. Ensure all the prerequisites from the Prerequisites page are complete. 
  2. Login to the respective Exchange Server and open the Exchange Management Shell using the same user credentials used for monitoring. Then, run the following commands to verify data retrieval:
    1. Get-MailboxDatabase
    2. Get-Mailbox
  3. Make sure that all the services related to the Exchange Server are running on the target server.

2. Execute Scripts Used in Applications Manager

  1. Open PowerShell in Administrator mode on the machine where Applications Manager is installed.
  2. Navigate to the <AppManager-Home>\working\conf\application\scripts\powershell directory.
  3. Execute the appropriate command by replacing hostname, username, and password with the credentials of the Exchange server used in Applications Manager:
    1. For Database Statistics:
    Quote.\E201X_MBX_Tables.ps1 'hostname' 'username' 'password
    1. For Top and Inactive Mailboxes:
    Quote.\EX_Mailbox_Statistics.ps1 'hostname' 'username' 'password
  4. Check if you get the expected output.
Notes
  1. If you encounter an error related to New-PSSession, or the WinRM service, recheck the Powershell prerequisites and try to resolve the same.
  2. The script uses Kerberos Authentication to create the Exchange PS Session. If it fails, it falls back to Basic Authentication.
  3. If error occurred while creating session, both the authentications have failed.
  4. Follow the below steps from the Prerequisites page to enable Basic Authentication.

3. Run Direct Commands from Applications Manager Server

  1. Open PowerShell in Administrator mode on the machine where Applications Manager is installed.
  2. Run the following commands one by one, replacing <hostname> with the Exchange Server hostname/IP-address in the first command alone. Run the remaining commands as mentioned below. Enter the Username and Password when prompted (use the same values as used in the Exchange Server monitor).
Quote$Hostname = '<hostname>'

$ServerName = [System.Net.Dns]::gethostentry($Hostname).HostName

$ServerName

$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck

$exsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://$ServerName/powershell"  -AllowRedirection -Authentication Kerberos -Credential Get-Credential -SessionOption $so
(Attempt Kerberos authentication, if failed try below command for Basic Authentication)

$exsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://$ServerName/powershell" -Authentication Basic -Credential Get-Credential -SessionOption $so
(If Basic Authentication fails, ensure above mentioned prerequisites are completed)

Import-PSSession $exsession -AllowClobber -DisableNameChecking | out-null

Get-MailboxDatabase

Get-Mailbox
  1. Verify that the above commands execute without any errors. 
Notes
  1. The above are commands directly provided by Microsoft. If they fail, Applications Manager will not be able to collect the data either.
  1. Contact your Server team or Microsoft support for assistance if you continue to face issues as these are standard commands for Exchange Server.

4. Run Direct Commands on the Exchange Server

  1. Log in to the respective Exchange Server that is being monitored.
  2. Open the Exchange Management Shell.
  3. Run the following commands (replace <hostname> with the same hostname/IP-address used in the Exchange Server monitor): 
QuoteQuote
$Hostname = '<hostname>'

$ServerName = [System.Net.Dns]::gethostentry($Hostname).HostName

$ServerName

$ServerHostname = $ServerName.split(".")[0]
  1. Run the relevant commands listed below to fetch specific metrics.

Commands used in the script to fetch specific metrics

  1. Database Statistics:
Info
Get-MailboxDatabase -Server $ServerHostname -Status | Select-Object MasterType, MasterServerOrAvailabilityGroup, Name, Mounted,@{Name="MailboxCount";Expression={(Get-Mailbox -Database $_.name -ResultSize Unlimited).Count}},@{name="databasesize"; expression={[math]::Round(($_.databasesize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1GB),2)}},@{name="availablenewmailboxspace"; expression={[math]::Round(($_.availablenewmailboxspace.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1GB),2)}}, LastFullBackup, @{name="age"; expression={(New-TimeSpan -Start $_.LastFullBackup -End $currentdate).Days}}, CircularLoggingEnabled | ConvertTo-Csv -Delimiter "|"  -NoTypeInformation | % {$_.Replace('"','')} | select -skip 1
  1. Database Availability Groups:
Info
Get-DatabaseAvailabilityGroup
  1. Database Copy Statistics:
Info
Get-MailboxDatabase -Server $ServerHostname -Status | Get-MailboxDatabaseCopyStatus | Select-Object name, Status, CopyQueueLength, ContentIndexState, LatestFullBackupTime, @{name="age"; expression={(New-TimeSpan -Start $_.LatestFullBackupTime -End $currentdate).Days}}, ActiveCopy | ConvertTo-Csv -Delimiter "|"  -NoTypeInformation | % {$_.Replace('"','')} | % {$_.Replace('\','- ')} |select -skip 1
  1. Top Mailboxes:
Info
Get-Mailbox -Server $ServerHostname -ResultSize Unlimited -wa SilentlyContinue | Get-MailboxStatistics -wa SilentlyContinue  | Sort-Object TotalItemSize -Descending | Select-Object -First 10 |  Select-Object DisplayName,@{name="TotalItemSizeMB"; expression={[math]::Round(($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}},ItemCount | ConvertTo-Csv -Delimiter "|"  -NoTypeInformation | % {$_.Replace('"','')} | select -skip 1
  1. Inactive Mailboxes:
Info
Get-Mailbox -Server $ServerHostname -ResultSize Unlimited -WarningAction SilentlyContinue |where {(!$_.name.startswith("SystemMailbox")) -and (!$_.name.startswith("FederatedEmail")) -and (!$_.name.startswith("DiscoverySearchMailbox"))}| Get-MailboxStatistics  -WarningAction SilentlyContinue | Select-Object DisplayName,LastLogonTime, @{name="DaysSinceLogin"; expression={((Get-Date) - $_.LastLogonTime).Days}} | where DaysSinceLogin -gt 30 | Sort-Object DaysSinceLogin -Descending | ConvertTo-Csv -Delimiter "|"  -NoTypeInformation | % {$_.Replace('"','')} | select -skip 1
  1. Exchange Queues:
Info
Get-Queue | Select-Object Identity,DeliveryType,Status,MessageCount,Velocity,NextHopDomain | ConvertTo-Csv -Delimiter "|"  -NoTypeInformation | % {$_.Replace('"','')} | % {$_.Replace('\','\\')} | select -skip 1

                  New to ADSelfService Plus?