Solved

powershell exchange 2013 inserting count

Posted on 2016-09-14
5
41 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thank you guys your response is awesome and quick
0
 

Author Closing Comment

by:techdrive
Comment Utility
Always awesome subsun
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now