Avatar of techdrive
techdriveFlag for United States of America

asked on 

powershell exchange 2013 inserting count

I have some code here and trying to find databases with users over a certain amount only to display. For example I only wanted to list databases with users who have 80 or more users

[code][/$exchservers = Get-Exchangeserver
foreach($exchserver in $Exchservers)
{
get-mailbox -Server $exchserver.name | Group-Object Database | Select-object Count,Name,Databasesize,Lastfullbackup
$exchserver.name
} code]

I tried this and it seem like it should work but did not. Please help

$exchservers = Get-Exchangeserver
foreach($exchserver in $Exchservers)
{
get-mailbox -Server $exchserver.name | Group-Object Database | where {$_.database.count -gt "80"} | Select-object Count,Name,Databasesize,Lastfullbackup
$exchserver.name
}
PowershellExchange

Avatar of undefined
Last Comment
techdrive
Avatar of SubSun
SubSun
Flag of India image

Use Get-MailboxDatabase to get the status of the database..
Try...
$exchservers = Get-Exchangeserver
foreach($exchserver in $Exchservers)
{
 Get-Mailbox -Server $exchserver.name | 
    Group-Object Database  | 
      ? {$_.count -gt "80"} | % {
        $Count = $_.Count
        Get-MailboxDatabase $_.Name -Status | Select  @{N="Count";E={$Count}},Name,Databasesize,Lastfullbackup,Server
   }
}

Open in new window

Avatar of Akhater
Akhater
Flag of Lebanon image

This should work for you

P.S. you are on Exchange 2013 you should start with Databases and not servers since a database can be hosted on more than one server (DAG)
$DBs = Get-MailboxDatabase

foreach($DB in $DBs)
{
		$MBXs = Get-Mailbox -Database $DB -ResultSize Unlimited
		if($MBXs.Count -gt 80){
			Write-Host "$DB has $($MBXs.Count) Mailboxes"
		}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of techdrive
techdrive
Flag of United States of America image

ASKER

thank you guys your response is awesome and quick
Avatar of techdrive
techdrive
Flag of United States of America image

ASKER

Always awesome subsun
Exchange
Exchange

Exchange is the server side of a collaborative application product that is part of the Microsoft Server infrastructure. Exchange's major features include email, calendaring, contacts and tasks, support for mobile and web-based access to information, and support for data storage.

213K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo