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
Follow Me