Tiele Declercq
Tiele Declercq

Reputation: 2130

Get-mailboxstatistics from all Office 365 Mailboxes

I need the LastLogonTime from all our cloud hosted mailboxes. Google tells me to

Get-Mailbox | Get-MailboxStatistics

Get-Mailbox currently returns 2172 mailboxes but when returning the entire object to Get-MailboxStatistics, it's giving an error on 59 mailboxes: The specified mailbox "Firstname Lastname" isn't unique.

For some of these mailboxes I can indeed find a Mailbox with a duplicate DisplayName but not for all.

So there are some Mailboxes without a valid Get-MailboxStatistics result. But when I ask the Get-MailboxStatistics from the ExchangeGuid, the record IS returned. I.e.

Get-MailboxStatistics -Identity 7045326a-5c0f-4a84-aa0c-ceb$$$$c67fe

When I modify my script to loop the mailbox results and query the statistics for each mailbox, I get the (obvious) response: The request is not serviced on the server. Your request is too frequent. Please wait for few minutes and retry again.

So.. my question is.. How do I pipe the ExchangeGuid of every Get-Mailbox record to the Get-MailboxStatistics?

Get-Mailbox -ResultSize 5 | Select-Object ExchangeGuid | Get-MailboxStatistics

returns:

The input object cannot be bound to any parameters for the command either because the command does not take pipeline in put or the input and its properties do not match any of the parameters that take pipeline input.
    + CategoryInfo          : InvalidArgument: (@{ExchangeGuid=...5-684390d4a758}:PSObject) [Get-MailboxStatistics], P    arameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Get-MailboxStatistics
    + PSComputerName        : outlook.office365.com

Upvotes: 0

Views: 7758

Answers (1)

Loïc MICHEL
Loïc MICHEL

Reputation: 26140

You can try to use the UPN (User Principal Name) which is unique :
get-mailbox -ResultSize 5 |select -expand userprincipalname |Get-MailboxStatistics

Upvotes: 3

Related Questions