0

I've found numerous codes online and have created the following to run a basic report on quotas and sizes of mailboxes on our SBS 2008 server (Exchange 2007):

get-mailbox -server HYDROMAIN -ResultSize unlimited | ft DisplayName,ProhibitSendReceiveQuota,ProhibitSendQuota,@{label="Mailbox Size(MB)";expression={(get-mailboxstatistics $_).TotalItemSize.Value.ToMB()}}

I would like to run the same report, weekly (on, say, Friday's), automatically, but have the report sorted from largest mailbox size to smallest. The report can be emailed in a .txt file or just in the body of the email. Or would it be better to sort by mailboxes that are the closest to their quotas? Or, is it possible to sort by mailbox size, and highlight (or differentiate) ones that are close to (or surpassed) their quotas?

Email sent to one specified address with custom subject and body header above the actual content (if not attached in .txt).

Would anyone be able to help me out? This is slightly above my understanding of the Exchange PowerShell. I'm very new to it and have only been using it for a few weeks.

I know it's probably pretty basic but I've been unable to get anything to work.

Thanks :)

Logan
  • 27
  • 1
  • 2
  • 8
  • Pipe your current command to Sort-Object mailboxsize ( which will be the name of the property you want to sort by) -desc. That will sort in descending order. – Davidw Feb 10 '14 at 02:01
  • I don't have an object called mailboxsize. And I'm unsure where to place that. I've changed the object name and placed it in the command but it's not working. Could you advise where to place it and what the object should be called (I'm using TotalItemSize from the mailbox stats) – Logan Feb 10 '14 at 02:20
  • Substitute TotalItemSize for mailbox size in my script. – Davidw Feb 10 '14 at 03:08
  • That's what I did and it didn't work so I'm assuming it was added in the wrong location of the script/command. Can you please show me exactly where it should be going in my script please. – Logan Feb 10 '14 at 03:10
  • Put the Sort-object before the format-list section. get-mailbox -server HYDROMAIN -ResultSize unlimited | Sort-Object TotalItemSize | ft DisplayName,ProhibitSendReceiveQuota,ProhibitSendQuota,@{label="Mailbox Size(MB)";expression={(get-mailboxstatistics $_).TotalItemSize.Value.ToMB()}} – Davidw Feb 10 '14 at 03:11
  • Doesn't seem to work - appears to be the same order as when that new piece wasn't in there. – Logan Feb 11 '14 at 00:24
  • Is it giving you an error? – Davidw Feb 11 '14 at 01:06
  • No error, just not ordered, same as is the new piece of code wasn't there. – Logan Feb 11 '14 at 01:09
  • Ah, I just noticed that I left out the -desc parameter after sort-object totallitemsize. – Davidw Feb 11 '14 at 01:15
  • Same thing.. odd.. unordered like before. – Logan Feb 11 '14 at 01:55
  • Try adding totalitemsize after the ft. – Davidw Feb 11 '14 at 02:01
  • This might help: https://serverfault.com/questions/336623/query-exchange-2007-remotely-for-a-users-mailbox-size-and-quota – Davidw Feb 11 '14 at 15:58
  • Still unordered - had a quick look at that link couldn't see anything that helped me.. ? – Logan Feb 12 '14 at 00:36
  • Anybody please? No one has setup a script to automatically run a powershell command and email results? Would be extremely handy in my current position. – Logan Feb 17 '14 at 20:27
  • Send the results of the script to Out-file and specify the file format you want, then create two scheduled tasks with task scheduler, one to run the script, and the second one to email you the file. As for sorting the output, please post the current script. – Davidw Feb 17 '14 at 21:14
  • Hey thanks I've managed to get the script to email me the results but now I can't get the script to run automatically, please refer to: http://serverfault.com/questions/576302/cannot-get-exchange-powershell-script-to-run-automatically – Logan Feb 17 '14 at 23:41

0 Answers0