3. Creating a report in HTML
PowerShell
is flexible in terms of processing output. Generated reports can show
management and others the kind of work that servers do. The typical
reports EMS generates are plaintext. You can also generate HTML reports
by piping objects through the ConvertTo-HTML cmdlet. (The Out-HTML
cmdlet at http://poshcode.org/1612
is also useful for generating HTML content.) This example explores how
to generate a useful report that shows mailboxes that have exceeded
their storage quota. You could use a report like this to check
proactively for users who are experiencing problems with their quota
and perhaps allocate them some additional quota to enable them to
resume working. The output is shown in Figure 2.
Get-Mailbox –Database VIP | Get-MailboxStatistics | Sort TotalItemSize –Descending | ConvertTo-HTML DisplayName, Database, ItemCount, TotalItemSize > C:\Temp\Mbxs.html
You
can enhance the output further by formatting the HTML with a style
sheet or adding other information such as the date and time of the
report. I leave that as an exercise for the reader.
It’s
worth noting that when you run the Get-MailboxStatistics cmdlet, you
force EMS to make a remote procedure call (RPC) to the Information
Store to retrieve the latest data for the mailboxes (individual,
database, or server). The information is completely up to date and
reflects the exact state of the mailbox rather than cached data that
could be a couple of hours old. The Store caches information about
mailbox quotas and updates the cache every two hours to avoid the
overhead of the I/O that it would otherwise need to generate to check
quotas every time a user attempts to send a message or to check that a
mailbox can accept a new message.
Troubleshooting Users report that they’ve deleted messages but still exceed quota
Given
the dynamic flow of messages in and out of mailboxes, it’s likely that
a small difference exists between the cached data and the actual state.
This sometimes causes confusion when a user reports that she has
exceeded quota and can’t send mail even though she has deleted many
messages, and she has to wait until the Store refreshes its cache to
determine the new mailbox size and respect the fact that she has
reduced the size under quota. If this becomes a problem and users
complain that Exchange takes too long before it allows them to resume
email activity, you can amend the system registry to force Exchange to
refresh the cache more often with the caveat that more frequent
refreshes impose an extra overhead on the server.