Home‎ > ‎

WARNING: The user hasn't logged on to mailbox Discovery Search Mailbox

posted Sep 2, 2015, 12:03 PM by Benny Skogberg   [ updated Sep 3, 2015, 12:27 PM ]

When we want to know the total storage of all the mailboxes we have in Office 365, we are encouraged to use PowerShell and Exchange Online cmdlets. Before we get to the state where we can run scripts against our Exchange Online we have used the scripts to do so.

#Connect to Office 365
$credential = Get-Credential
Import-Module MSOnline
Connect-MsolService -Credential $credential

#Connect to Exchange Online
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" –AllowRedirection

Import-PSSession $exchangeSession -DisableNameChecking

And we run the script against the mailbox – just to be informed that it doesn't work as expected.

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, StorageLimitStatus, TotalItemSize, TotalDeletedItemSize, ItemCount, DeletedItemCount | Export-CSV "C:\Temp\Mailboxes.csv" –NoTypeInformation

The output is something like this:

WARNING: The user hasn't logged on to mailbox 'DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E09334BB852}'('d907f6dc-f370-4e48-b1e6-28eaa0375409'), so there is no data to return. After the user logs on, this warning will no longer appear.

So you struggle and try to sign in to the Discovery Search Mailbox. I even tried to create rules in mine, just to nudge it a bit and maybe something would happen?! But I have an Office 365 Business Essential subscription, and needs an Exchange Online plan 2 to create rules – so back to square one.

Instead of this – we need to filter out the Discovery Search Mailbox when getting the real mailbox data. Instead of using the above script, you can use the following which also provides a warning in the end – but the benefit is that you get the data in your csv-file.

$mailboxes = Get-Mailbox -ResultSize Unlimited

foreach ($mailbox in $mailboxes)
 {
     if($mailbox.DisplayName -ne "Discovery Search Mailbox")
     {
         Write-Host $mailbox.DisplayName
         $mailbox | Get-MailboxStatistics | Select DisplayName, StorageLimitStatus, TotalItemSize, TotalDeletedItemSize, ItemCount, DeletedItemCount | Export-CSV "C:\Temp\Mailboxes.csv" –NoTypeInformation –Append
     }
 }

And you have the result to open up in MS Excel and modify to your liking.