Find the mailbox database size and the count of mailboxes on each database in the same powershell command and list in tabular form


hi all

please let me know how command working. never works way expect. hats off powershell gurus.

[ps] c:\windows\system32>get-mailboxdatabase -status | ft name,@{label="free space";expression={$_.availablenewmailboxspace.tomb()}},@{label="size";expression={$_.databasesize.tomb()}},@{name="number";expression={(get-mailbox -database $_.name).count}} | ft -autosize

any advice on how proceed on ? thanks.

show output:

$dbs = get-mailboxdatabase -status $data = @() foreach($db in $dbs) { 	$mxcount = (get-mailbox -database $db.name -resultsize unlimited).count 	$fspace  = $db.availablenewmailboxspace.tomb() 	$size 	 = $db.databasesize.tomb() 	$name	 = $db.name 	$data += new-object psobject -prop @{ 		"free space" = $fspace 		"size"		 = $size 		"number"     = $mxcount 		"name"		 = $name 	} }  $data | select name,"free space",size,number | format-table -auto



Windows Server  >  Windows PowerShell



Comments