Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

powershell exchange 2013 inserting count

Posted on 2016-09-14
5
Medium Priority
?
67 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
  • 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 2000 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
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…

824 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