Exchange 2010 SP2. Exchange forum suggested posting this over here.
I am trying to create an array containing the results of get-mailboxdatabase (name,size, provisioning) but to also include a count of mailboxes on each database. I'd like to end up with an array that I can filter on and then pipe to set-mailboxdatabase. For example, if the mailbox count or the database size exceeds a certain threshold, then we want to exclude that database from provisioning.
I've tried the code below, but it's not getting the data in the right format. The goal would be to run something like
$Mbxcounts | where {$_.Size -gt 50GB} | set-mailboxdatabase -isexcludedfromprovisioning:$true
Here is what I've tried:
$Mbxcounts = get-mailboxdatabase -status | sort-object name | select name,@{n="Mailboxes";e={(get-mailbox -database $_.name).count}},IsExcludedFromProvisioning,DatabaseSize | foreach { new-object PSObject -prop @{ Name = $_.Name; Mailboxes = $_.Mailboxes; Provisioning = $_.IsExcludedFromProvisioning; Size = $_.DatabaseSize } }