PS or VB Script to get customized mailbox statistics
I want to generate a daily report for specific executive users mailbox details in csv file in following format using csv import file which will have users SMTP address. DisplayName,TotalItemSize (MB),ItemCount,Server\SG\DB,DB Size (GB),DB Free Space (GB) DB free space will be actually SAN disk free space and all my exchange servers DBs, logs are on SAN. Every database and logs has its own SAN disk. Any help with script will be appreciate. Hope to get positive reply asap. Thanks.Shahid
September 6th, 2011 12:21pm

Hi Shahid, You can Try this: $Report=@() import-csv c:\Account.csv| foreach{ $EmailAddress=$_.SMTP $DisplayName=(get-mailbox -identity $EmailAddress).DisplayName $database=(get-mailbox -identity $EmailAddress).database $TotalItemSize=(get-mailboxstatistics -identity $EmailAddress).TotalItemSize.value $ItemCount=(get-mailboxstatistics –identity $EmailAddress).ItemCount $DatabaseName=(get-mailboxdatabase -identity $database -status).Name $DatabaseSize=(get-mailboxdatabase -identity $database -status).DatabaseSize $DatabaseSpace=(get-mailboxdatabase -identity $database -status).AvailableNewMailboxSpace $obj=new-object System.Object $obj|add-member -membertype NoteProperty -name "DisplayName" -value $DisplayName $obj|add-member -membertype NoteProperty -name "TotalItemSize" -value $TotalItemSize $obj|add-member -membertype NoteProperty -name "ItemCount" -value $ItemCount $obj|add-member -membertype NoteProperty -name "DatabaseName" -value $DatabaseName $obj|add-member -membertype NoteProperty -name "DatabaseSize" -value $DatabaseSize $obj|add-member -membertype NoteProperty -name "DatabaseSpace" -value $DatabaseSpace $Report+=$obj } $Report|export-csv C:\report.csv -noType Note: I save email address in file (c:\Account.csv), like this type: SMTP User1@domain.com User2@domain.com ….. Use this command to export report at path: c:\report.csv Thanks, Evan
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2011 5:55am

Thanks Evan for your time and help. I will test this script in my lab and let you know the result.Shahid
September 9th, 2011 11:35am

Evan, I ran ths PS script in my lab and i got the output but not as expected. It did not retrun he DB and Disk Space data, only MBX data. I need to get the data of MBX in MB and DB and Disk space data in GB. Shahid
Free Windows Admin Tool Kit Click here and download it now
September 9th, 2011 12:18pm

Hi Shahid, What the version of your Exchange Server? This can work in my lab (Exchange 2010 SP1): $Report=@() import-csv c:\Account.csv| foreach{ $EmailAddress=$_.SMTP $DisplayName=(get-mailbox -identity $EmailAddress).DisplayName $database=(get-mailbox -identity $EmailAddress).database $TotalItemSize=(get-mailboxstatistics -identity $EmailAddress).TotalItemSize.value $ItemCount=(get-mailboxstatistics -identity $EmailAddress).ItemCount $DatabaseName=$database.Name $DatabaseSize=(get-mailboxdatabase -identity $DatabaseName -status).DatabaseSize $DatabaseSpace=(get-mailboxdatabase -identity $DatabaseName -status).AvailableNewMailboxSpace $obj=new-object System.Object $obj|add-member -membertype NoteProperty -name "DisplayName" -value $DisplayName $obj|add-member -membertype NoteProperty -name "TotalItemSize(MB)" -value $TotalItemSize.ToMB() $obj|add-member -membertype NoteProperty -name "ItemCount" -value $ItemCount $obj|add-member -membertype NoteProperty -name "DatabaseName" -value $DatabaseName $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB() $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB() $Report+=$obj } $Report|export-csv C:\report.csv –noType If this cannot work in your environment, please describe your environment in detail. Thanks, Evan
September 13th, 2011 10:03am

My exchange version is E2K7+SP1+RU5+IU and when i run your updated script mentioned above i got following error. You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:33 char:92 + $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:36 char:94 + $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:33 char:92 + $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:36 char:94 + $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:33 char:92 + $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:36 char:94 + $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:33 char:92 + $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:36 char:94 + $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:33 char:92 + $obj|add-member -membertype NoteProperty -name "DatabaseSize(GB)" -value $DatabaseSize.ToGB( <<<< ) You cannot call a method on a null-valued expression. At C:\scripts\Shahid\ExecMbxReport.ps1:36 char:94 + $obj|add-member -membertype NoteProperty -name "DatabaseSpace(GB)" -value $DatabaseSpace.ToGB( <<<< ) Shahid
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2011 11:39am

This is some commands only work in Exchange 2010 SP1, it not work in Exchange 2007. $DatabaseSize=(get-mailboxdatabase -identity $database -status).DatabaseSize $DatabaseSpace=(get-mailboxdatabase -identity $database -status).AvailableNewMailboxSpace I will try to edit in Exchange 2007, and post the updates. Thanks, Evan
September 15th, 2011 12:59pm

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

Other recent topics Other recent topics