Solved

powershell exchange 2013 inserting count

Posted on 2016-09-14
5
46 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Find out what you should include to make the best professional email signature for your organization.
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 >>…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

772 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