Task – Get A List Of Mailboxes That Was Created In The Last One Week…

I had to get a list of mailboxes that was created in the last one week. Though it is quite easy, I thought that I will share it anyway.

Get-Mailbox | Where-Object {$_.WhenCreated –ge ((Get-Date).Adddays(-7))}

The above command will give you a list of all mailboxes that was created in the last one week, but may not bring the properties that you are looking for. Modify the command with the values you need. For example,

Get-Mailbox | Where-Object {$_.WhenCreated –ge ((Get-Date).Adddays(-7))} | ft name, servername, database

You can export the result to a txt or csv file.

Get-Mailbox | Where-Object {$_.WhenCreated –ge ((Get-Date).Adddays(-7))} | ft name, servername, database | Out-File C:mailboxes.txt

Get-Mailbox | Where-Object {$_.WhenCreated –ge ((Get-Date).Adddays(-7))} | ft name, servername, database | Export-CSV c:mailboxes.csv

It is easy to extend the command to find a list of mailboxes that was created in the last one month. For the month of August, run

Get-Mailbox | Where-Object {($_.WhenCreated).Month –eq 8} | ft name, servername, database

Note that the value of month takes an integer.

Piping the above command to Meaure-Object will give you the number of mailboxes that was created.

Get-Mailbox | Where-Object {($_.WhenCreated).Month –eq 8} | Measure-Object

To get the list for the year 2009, run

Get-Mailbox | Where-Object {($_.WhenCreated).Year –eq 2009} | ft name, servername, database

5 Responses to “Task – Get A List Of Mailboxes That Was Created In The Last One Week…”

  1. Deepak Khandelwal October 1, 2009 at 9:47 am #

    It is amasing what Powershell can do for you.. Thanks for sharing

    [Reply]

  2. Rajith Jose Enchiparambil October 1, 2009 at 10:28 am #

    Powershell is the future!

    [Reply]

  3. Paul Cunningham October 1, 2009 at 11:56 pm #

    Great tip, thanks for that!

    [Reply]

  4. Rajith Jose Enchiparambil October 2, 2009 at 8:57 am #

    Thanks Paul.

    [Reply]

  5. Anonymous November 27, 2009 at 10:21 pm #

    PowerShell does indeed rock, however that query is returning the date/time stamp when the user object was created not when the mailbox was created. If the mailbox always get's created right after the user account then that's good data. Unfortunately for me, I've got in some cases a few months before some user accounts get a mailbox.

    [Reply]

Leave a Reply:

Gravatar Image