Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Creating array from get-mailboxdatabase that includes mailbox counts

$
0
0

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
		}
	}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>