Monday, December 15, 2014

Easily get the Name and size of all Database (Tested in Exchange 2010/2013/2016)

Heres all you have to do: My script is actually on technet and it has been updated today: 08/28/2017
# Version 1.0 GB
# Created and personalized by Jose Ortega jortega928@yahoo.com
$Space=1GB #So you can get the space in GBs (you can change this to 1MB to get the size in MB)
$decimal=4 #4 decimals
  
Get-MailboxDatabase | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server     -filter ('name=''' + $_.edbfilepath.pathname.replace("\","\\") + '''')).filesize / $Space),$decimal)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB
Heres the output: Or if you need the size in MB.
# Version 1.0
# Created and personalized by Jose Ortega jortega928@yahoo.com
$Space=1MB #So you can get the space in MB (you can change this to 1GB to get the size in GB)
$decimal=4 #4 decimals
  
Get-MailboxDatabase | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinMB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server     -filter ('name=''' + $_.edbfilepath.pathname.replace("\","\\") + '''')).filesize / $Space),$decimal)) -passthru} | Sort-Object mailboxdbsizeinMB -Descending | format-table identity,mailboxdbsizeinMB
You can save this code into a notepad file and keep it as "DatabaseSizeinfo.ps1"

Please consider to donate and thank you very much for reading this.

No comments:

Post a Comment