Exchange 2007 Power Shell Command
Hello all,I am looking to dump a report of all my mailboxes with the following information in the report:DisplayName, Database, TotalItemSize, DepartmentHowever, because "Department" is a user attribute rather than a mailbox attribute, I am struggling with find a way to get this included in the output. I've created the below command which seems to work OK, but I would have to run it for every different department,which means 35+seperate reports. I really need this to be one scriptthat puts everything into the same CSV file.get-user -Filter {department -eq "CCIR" -and RecipientType -eq "UserMailbox"} | get-mailbox | get-mailboxstatistics | sort-object totalitemsize -desc | select-object @{Name="User Name";expression={$_.displayname}},@{Name="Total Size (MB)";expression={$_.totalitemsize.value.toMB()}},@{Name="Storage Group";expression={$_.database}} | export-csv -notype c:\temp\ccir.xlsThis command seems to work for creating the report and sorting it by "Department" name, but I cannot figure out how to get the Department field to actually be included in the export. get-user -Filter {recipienttype -eq "UserMailbox"} | sort-object department -desc | get-mailbox | get-mailboxstatistics | select-object displayname,database,totalitemsize,departmentThanks in advance for your help!NickNick Cozby
December 18th, 2008 7:20pm

First go tohttp://www.quest.com/powershell/activeroles-server.aspxand download the Quest Powershell AD cmdlets.Then run the following commandget-mailbox | select@{Name="User Name";expression={$_.displayname}},@{Name="Department";expression={(get-QADUser $_.samaccountname).department}},@{Name="Storage Group";expression={$_.database}},@{Name="Total Size (MB)";expression={(get-mailboxstatistics $_).totalitemsize.value.toMB()}} | export-csv -notypeinformation c:\temp\userdmp.csvThe cool trick to this is that you can run cmdlets in the expression section of your select statement. Also if you have over 1000 mailboxes remember to used the -resultsize unlimited after get-mailbox Sr. Exchange Engineer - Constellation Energy
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2008 7:56pm

This works perfectly Aaron...! I just tested it with get-user (without Quest AD CmdLet) and that has also give expected result... get-mailbox | select@{Name="User Name";expression={$_.displayname}},@{Name="Department";expression={(get-user $_.alias).department}},@{Name="Storage Group";expression={$_.database}},@{Name="Total Size (MB)";expression={(get-mailboxstatistics $_).totalitemsize.value.toMB()}} | export-csv -notypeinformation c:\temp\userdmp.csvAmit Tank || MVP - Exchange || MCITP - Exchange 2007 || http://ExchangeShare.WordPress.com
December 18th, 2008 8:20pm

No problem, I just prefer the Quest AD cmdlets because it allows you access to all the attributes on the AD object whereas the Exchange cmdlets are limited.Sr. Exchange Engineer - Constellation Energy
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2008 8:23pm

Yep, I agree on that part....Amit Tank || MVP - Exchange || MCITP - Exchange 2007 || http://ExchangeShare.WordPress.com
December 18th, 2008 8:25pm

This works great, thanks for your help!!NickNick Cozby
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2008 8:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics