A reader asks:
I have been trying to get a script that can log into mailboxes automatically. The reason is that I have 500 mailboxes and when I attempt to query their statistics I get an error that the mailbox has never been logged into and therefore can’t generate any stats.
Let’s take a quick look at the issue itself. When a new mailbox is created and you attempt to use Get-MailboxStatistics to query the mailbox, you will receive a warning similar to this.
WARNING: The user hasn’t logged on to mailbox ‘exchangeserverpro.net/Company/Branch Office/Users/Blake Johnson’
(‘0971ff8e-d6d1-4bd6-98b9-384b35103a2d’), so there is no data to return. After the user logs on, this longer appear.
In itself this is not a problem, but it might produce undesirable results for some mailbox reporting tasks, or at the very least make them a little more difficult.
The idea of creating a script that automatically logs on to new mailboxes is one approach to solving the problem. However it is probably more difficult than another solution which is also available.
That other solution is to simply send the mailbox an email. Once you do that the Get-MailboxStatistics cmdlet will return a result for the mailbox like this:
[PS] C:\>get-mailbox blake.johnson | Get-MailboxStatistics | ft -auto
DisplayName ItemCount StorageLimitStatus LastLogonTime
----------- --------- ------------------ -------------
Blake Johnson 1 BelowLimit
But is it practical to send 500 mailboxes an email? If it is a test lab you could simply add them all to one distribution group, and send that group an email. It would take just a few moments.
If it is a production system and new mailboxes are created regularly, you can automate the task. MVP Pat Richard has written a PowerShell script that can be run as a scheduled task to automatically send a welcome email to new mailboxes. You can customize the welcome message to provide useful information to new users on the network. It really is a great idea if you ask me, plus it solves this issue with mailbox reporting. Check out Pat’s script here.