How to get exchange mailbox databasesize, freediskspace, mailbox count and export to csv file with custom column RRS feed

  • Question

  • Hi guys,

            I got some exchange 2013 servers, and i want get my exchange mailbox server information about database name,size of database,free disk space for which database stored,mailbox count of each database and which server the database belongs to.

          I know database name,server name and databasesize can get by get-mailboxdatabase, freediskspace can get by get-mailboxdatabasecopystatus, mailbox count can get by get-mailbox, how can i combine these data and export them to a csv file with custom columns?

           Thank you for any reply.

    • Moved by Bill_Stewart Friday, July 27, 2018 9:15 PM This is not "debug/fix/rewrite my script for me" forum
    Friday, June 1, 2018 1:25 AM

All replies

  • Please post your script with any errors.

    Please read the following link.

    This Forum is for Scripting Question Rather than script requests


    Friday, June 1, 2018 1:49 AM
  • $MailBoxSrvs=Get-ExchangeServer | ?{$_.serverrole -eq "mailbox"} | select name

    $FreeSpace=$MailBoxSrvs | %{Get-MailboxDatabaseCopyStatus -Server $_.name | ?{$_.Status -eq "mounted"}} | Select databasename,mailboxserver,diskfreespace | sort databasename 

    $DBSize=$FreeSpace | %{Get-MailboxDatabase -Identity $_.databasename -Status | select id,server,databasesize} | sort id -Unique

    $MailboxCount=$FreeSpace|%{Get-Mailbox -ResultSize unlimited -Database $_.databasename | select database}|Group-Object database | select name,count | sort name

    I have two questions, First is that in my script i write the select command in the loop,but i also can write the select command after loop finished, which way is faster?  

    Second question is how can i extract the databasesize,servername,databasename,diskfreespace,count from that three array variables, and write those data into a new variable with custom colmuns?

    Friday, June 1, 2018 8:28 AM