Display Exchange Online reports with Office 365 PowerShell

 

上次修改主題的時間:2016-06-17

Summary: Use Office 365 PowerShell to get advanced reports for Microsoft Exchange Online.

With nearly 500 cmdlets at your disposal, there is plenty that you can do with Office 365 PowerShell and Exchange Online. This article steps you through a few examples.

Before you get started using Office 365 PowerShell to manage Microsoft Exchange Online, make sure that you have connected to Microsoft Exchange Online PowerShell. For more information, see Connect to Exchange Online PowerShell.

Administrators like to keep track of whether people are actually using the system. For example, maybe you’d like to know if there are users who haven’t opened their Outlook mailbox in the past week or the past month. Office 365 PowerShell is perfect for doing that type of reporting. For example, here’s a command that returns all the mailboxes that no one has logged onto since November 1, 2015:

Get-Mailbox | Get-MailboxStatistics | Where-Object {$_.LastLogonTime -lt "11/1/2015"}

Here’s a command that displays all the mailboxes that no one has ever logged onto:

Get-Mailbox | Get-MailboxStatistics | Where-Object {$_.LastLogonTime -eq $Null}

Here’s how you can get a list of users who have more than 10,000 items in their mailbox:

Get-Mailbox | Get-MailboxStatistics | Where-Object {$_.ItemCount -gt 10000}

Here are just a few of the many Office 365 PowerShell cmdlets that can be used to return reporting information and statistics:

註記注意事項:
If you look closely at the list, you might notice the Get-CsConferenceReport cmdlet. The Get-Cs portion of that cmdlet name suggests that this is a Lync Online cmdlet, not an Exchange Online cmdlet.
This cmdlet (as well as other Get-Cs reporting cmdlets) does return information about Lync Online, and it was created by the Lync Online team. However, the Get-Cs reporting cmdlets require the Exchange Online reporting service in order to generate and return data. That means you must have a subscription to Exchange Online in order to use these cmdlets; if you don’t have a subscription to Exchange Online then you won’t have access to the reporting service. Because of that, these cmdlets are included in the Exchange module rather than the Lync Online module. If you start Windows PowerShell and load only the Lync Online module, you will not see any of the Get-Cs reporting cmdlets. You need to load the Exchange module in order to generate Lync Online reports.

Get-MailboxStatistics is designed to return detailed information about user mailboxes. For example, this command:

Get-MailboxStatistics -Identity "alexd"

Displays the following:

DisplayName    ItemCount    StorageLimitStatus    LastLogonTime
-----------    ---------    ------------------    -------------
Alex Darrow    29                                 10/8/2013 3:18:05 PM

By default, you see the total number of items in Alex’s mailbox (ItemCount) and the last time Alex logged on (LastLogonTime).

For another example, maybe you'd like to know the total size of the items in Alex’s mailbox:

Get-MailboxStatistics -Identity "alexd" | Select-Object DisplayName, TotalItemSize

Or maybe you’d like to know the number of deleted items in Alex’s mailbox:

Get-MailboxStatistics -Identity "alexd" | Select-Object DisplayName, DeletedItemCount

Or maybe you’d like to know both:

Get-MailboxStatistics -Identity "alexd" | Select-Object DisplayName, TotalItemSize, DeletedItemCount

To see all the property values that can be returned using the Get-MailboxStatistics cmdlet, run a command similar to this:

Get-MailboxStatistics -Identity "alexd" | Select-Object *

You are not limited to having to look at mailbox statistics one mailbox at a time. If you want a report listing information about all your mailboxes, here is the command:

Get-Mailbox | Get-MailboxStatistics

That command will return information similar to this:


DisplayName    ItemCount  StorageLimitStatus    LastLogonTime
-----------    ---------  ------------------    -------------
Alex Darrow     29                              10/8/2013 1:18:05 PM
Allie Bellew    3                               11/8/2013 9:18:21 PM
Anne Wallace    3                               10/21/2013 3:18:45 PM
Aziz Hassouneh  2                               10/18/2013 2:19:05 PM
Belinda Newman  21                              10/4/2013 3:19:26 PM
Bonnie Kearn    13                              10/8/2013 8:19:50 PM

You also aren’t limited to two options here: getting back information for one mailbox, or getting back information for all your mailboxes. Instead, you can write all sorts of clever little Office 365 PowerShell commands that return information for a subset of mailboxes. Need information just for three of your mailboxes? Simply specify the identifying information prior to the Get-MailboxStatistics command. Here is an example:

"Alex Darrow", "Allie Bellew", "Anne Wallace" | Get-MailboxStatistics

This command returns data just for the three specified mailboxes:

DisplayName    ItemCount  StorageLimitStatus    LastLogonTime
-----------    ---------  ------------------    -------------
Alex Darrow     29                              10/8/2013 1:18:05 PM
Allie Bellew    3                               11/8/2013 9:18:21 PM
Anne Wallace    3                               10/21/2013 3:18:45 PM

Or maybe you’d like to generate a report for all the mailboxes belonging to the Finance department. That can be done with a command similar to this:

Get-User -Filter '{Department -eq "Finance"}' | Get-MailboxStatistics
 
顯示: