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

MS Exchange

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

Please let me know if you have any questions in the comments section.

Other Popular Articles


MS Exchange

Scripting Agent Initialization Failed: “File is not found” Error During Exchange 2016 Setup

MS Exchange

EAC Access While Co-Existing Exchange 2013 With 2010

MS Exchange

Delete All Calendar Entries In An Exchange 2010 Mailbox

13 thoughts on “Get A List Of Mailboxes That Was Created In The Last One Week”

  1. I want to get list of shared mailbox sorted by creation date. But record would be more than 5000. So can we implement some pagination kind of thing in power shell ? If yes how can I achieve that?

    Reply
  2. Include the parameter
    -resultsize unlimited
    to search more than the the default 1000 items

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

    Reply
  3. The attribute WhenCreated represents the date the AD account was created, not the date the mailbox was created (which might be days or months before the creation of the mailbox, depending on your situation).

    Use the attribute WhenMailboxCreated instead to filter the mailbox creation date.
    E.g:
    Get-Mailbox | Where-Object {$_.WhenMailboxCreated –ge ((Get-Date).Adddays(-7))} | ft name, servername, database

    Reply
  4. thx for these great tipps!

    I would like to have a overview for 3month… (e.g. Januar Februar March)
    And if i export the file I need “;” between the entries.

    Any Ideas?

    Thx
    David

    Reply
  5. 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 Comment