Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

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
0
beardog1113
Asked:
beardog1113
  • 2
  • 2
1 Solution
 
QlemoC++ 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.
0
 
beardog1113Author Commented:
hello
while i promote both command, there nothing displayed, how can i check the result?

thank you
0
 
QlemoC++ 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.
0
 
beardog1113Author Commented:
cool
thanks
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now