count mailbox via Exchange power shell

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
Who is Participating?
QlemoConnect With a Mentor Batchelor and DeveloperCommented:
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.
QlemoBatchelor and DeveloperCommented:
  $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.
beardog1113Author Commented:
while i promote both command, there nothing displayed, how can i check the result?

thank you
beardog1113Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.