Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Measure-Object is the correct way to use?

$
0
0

I wrote PS script to collect all mailboxes from one exchange server and print in email report with mailboxdisplayname, TotalItems. stored in $Jm before formatting I want to total mailbox count and sum or TotalItems. I called another veriable $jmsummary. I got all count and sum but when i try to print that in email report -body I am not successful.

output of $JMsummary

Count    : 45
Average  : 20.8
Sum      : 936
Maximum  : 358
Minimum  : 1
Property : TotalItems

 

here is the script

$jm = Get-WmiObject -ComputerName <copmname> -Credential $cred -Namespace "root/microsoftExchangev2" -Class "exchange_mailbox" |`
where {$_.mailboxdisplayname -like 'EXJ*'}
$jmsummary = ($jm | Measure-Object -Property TotalItems -Sum -Average -Maximum -Minimum )
$body = $jm | sort totalitems -Descending| ft -AutoSize |Out-String

$summary = "Total JM mailbox Count = $jmsummary.count`n+
            Total JM Mailbox Email Count = $jmsummary.sum" | out-string

$fr = "EMAILID"
$to = "EMAILID"
$smtp = "SMTPservername"
Send-MailMessage -To $to -From $fr -Subject "JM status" -SmtpServer $smtp -Body "$summary $body"


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images