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.