Solved

powershell exchange 2013 inserting count

Posted on 2016-09-14
5
52 Views
Last Modified: 2016-09-16
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
}
0
Comment
Question by:techdrive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 41799498
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

0
 
LVL 49

Expert Comment

by:Akhater
ID: 41799509
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

0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41799517
Or Using Get-Mailbox..
$Mailboxes = Get-Mailbox -ResultSize Unlimited -Server fahqsna09sxmb01
$Mailboxes | 
    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

0
 

Author Comment

by:techdrive
ID: 41799660
thank you guys your response is awesome and quick
0
 

Author Closing Comment

by:techdrive
ID: 41801208
Always awesome subsun
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question