1

How do I suppress warnings from Exchange 2010's PowerShell Get-MailboxStatistics cmdlet?

I've tried both of these options:

Get-MailboxStatistics -WarningAction SilentlyContinue
Get-MailboxStatistics -ErrorAction SilentlyContinue

However I still get this warning output to the console about users that's haven't logged onto their mailboxes:

WARNING: The user hasn't logged on to mailbox ...[snipped]..., so there is no data to return. After the user logs on, this warning will no longer appear.

4
  • I also tried $WarningActionPreference = "SilentlyContinue" --This will set all warning messages to silent. Looks like something is broken. Looks like there is a bug. connect.microsoft.com/PowerShell/feedback/details/541500/…
    – st3v3o
    Feb 28, 2011 at 17:54
  • @st3v3o - why not make that an answer and get set up for some bounty?
    – Kev
    Feb 28, 2011 at 18:04
  • good call..but I'm not sure I really full answered the question...but worth a shot :P
    – st3v3o
    Feb 28, 2011 at 18:17
  • oh I didn't realize you answered the question sorry Kev.
    – st3v3o
    Feb 28, 2011 at 18:19

2 Answers 2

4
+100

I also tried $WarningActionPreference = "SilentlyContinue" --This will set all warning messages to silent. Looks like something is broken. Looks like there is a bug.

https://connect.microsoft.com/PowerShell/feedback/details/541500/warning-verbose-and-debug-streams-do-not-respect-action-preferences-the-way-they-should

2
  • +1 You'll probably win this, but I'll leave to run until the end of the bounty before awarding.
    – Kev
    Feb 28, 2011 at 22:50
  • 1
    FWIW I was doing some additional testing and just running Get-MailboxStatistics -Database <DB NAME> will output all of the users and system boxes that are listed. It will however skip over user accounts that have no statistical data to output (without displaying a warning)
    – st3v3o
    Mar 1, 2011 at 14:17
4

I've been playing with this one, trying to recreate the issue (I'm on Exhcange 2007, though, so this may make a difference. I'm also pretty new to powershell). Starting with a new mailbox, "Testy McTest":

>get-variable |where { $_.Name -match "Preference" }

Name                           Value
----                           -----
ConfirmPreference              High
DebugPreference                SilentlyContinue
ErrorActionPreference          Continue
ProgressPreference             Continue
VerbosePreference              SilentlyContinue
WarningPreference              Continue
WhatIfPreference               False

I can run the following:

>Get-MailboxStatistics "Testy McTest"
WARNING: There is no data to return for the specified mailbox 'Testy McTest', because it has not been logged on to.
>Get-MailboxStatistics -WarningAction SilentlyContinue "Testy McTest"   (No Output)
>Set-Variable WarningPreference SilentlyContinue
>Get-MailboxStatistics "Testy McTest"   (No output)
>

This seems to work as normal. It might be worth mentioning that the variables for Error and Warning actions are actually ErrorActionPreference and WarningPreference. Not sure why they differ like that.

As a workaround for the specific command in the question, you could qualify the output, with something like:

>Get-MailboxStatistics |where { $_.LastLogonTime }

Which seems to list only those mailboxes that have a logon time.

2
  • Looks like things are slightly different in the Exchange powershell way of doing things between 2007 and 2010 ...I tried your above setting and still get output with the EMS for 2010.
    – st3v3o
    Mar 1, 2011 at 14:20
  • @st3v3o - yep same here.
    – Kev
    Mar 1, 2011 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .