Solved

count mailbox via Exchange power shell

Posted on 2013-11-08
4
490 Views
Last Modified: 2013-11-08
hi experts
i want using get-mailbox command to count how many mailbox i have and show the result.
for example get-mailbox -database xxxxx
could you help me complete this command?

thank you
0
Comment
Question by:beardog1113
[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
4 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39632887
  $noMbx = @(get-mailbox -database xxxx).Count
should do that. @(...) forces the result to be an array, even if only one object is returned. For an array you can always use the Count property to get the number of objects. Simple, isn't it?

Another way, but less elegant, is:
  $noMbx = (get-mailbox -database xxxx | measure-object).Count
Measure-Object is used to get the number of objects, or the average, sum, max, min of numeric properties, or the line/word count of text stream.
0
 

Author Comment

by:beardog1113
ID: 39632961
hello
while i promote both command, there nothing displayed, how can i check the result?

thank you
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39632993
The result is in the var $noMbx, so just enter that name after executing one of above lines. or remove the leading part including the equal sign.
0
 

Author Closing Comment

by:beardog1113
ID: 39632995
cool
thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This Experts Exchange lesson shows how to use VBA to loop through rows in Excel.  In order to sort, filter, and use database features, there needs to be a value in each column for every row. When data arrives with values missing, code to copy values…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

632 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