Filter results to show count 20 or greater-TOTALLY STUCK
script needs pull sent totals exchange , show results 20 or greater. can populate every recipient want show 20 or more. if possible i'd current datestamp in teh heading well. have been reading , testing several hours-cant seem make sing :-(
tia
$a = "<style>"
$a = $a + "body{background-color:fff9ce;}"
$a = $a + "table{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "th{border-width: 2px;padding: 2px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "td{border-width: 2px;padding: 2px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
$fromaddress = "sentandrecievedtotals@any.com"
$toaddress = "any@any.com"
$messagesubject = "number of emails sent , recieved report"
$messagebody = "attached report email sent , recieved totals."
$sendingserver = "anyserver"
$start = (get-date -hour 00 -minute 00 -second 00).adddays(-1)
$end = (get-date -hour 23 -minute 59 -second 59).adddays(-1)
$results = @()
$sent = get-messagetrackinglog -server anyserver -eventid send -start $start -end $end -resultsize unlimited
$mailboxes = get-mailbox -server mailserver
$total = $mailboxes.count
$count = 1
$mailboxes | sort-object -property displayname | foreach-object {
$percentcomplete = $count / $total * 100
write-progress -activity "message tracking log search" -status "please hold.....processing mailboxes" -percentcomplete $percentcomplete
$stats = "" | select-object name,sent,received
$email = $_.windowsemailaddress.tostring()
$stats.name = $_.displayname
$stats.sent = ($sent | where-object { ($_.eventid -eq "send") -and ($_.sender -eq $email) }).count
$results += $stats
$count += 1
}
$results | sort-object sent -descending | convertto-html -head $a –body "<h2>sent email</h2>" | out-file c:\scripts\emailsendrecievestats1.html
###create mail message , add statistics text file attachment
$smtpmessage = new-object system.net.mail.mailmessage $fromaddress, $toaddress, $messagesubject, $messagebody
$attachment = new-object net.mail.attachment ("c:\scripts\emailsendrecievestats1.html")
$smtpmessage.attachments.add($attachment)
###send message
$smtpclient = new-object system.net.mail.smtpclient $sendingserver
$smtpclient.send($smtpmessage)
tia
$a = "<style>"
$a = $a + "body{background-color:fff9ce;}"
$a = $a + "table{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "th{border-width: 2px;padding: 2px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "td{border-width: 2px;padding: 2px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
$fromaddress = "sentandrecievedtotals@any.com"
$toaddress = "any@any.com"
$messagesubject = "number of emails sent , recieved report"
$messagebody = "attached report email sent , recieved totals."
$sendingserver = "anyserver"
$start = (get-date -hour 00 -minute 00 -second 00).adddays(-1)
$end = (get-date -hour 23 -minute 59 -second 59).adddays(-1)
$results = @()
$sent = get-messagetrackinglog -server anyserver -eventid send -start $start -end $end -resultsize unlimited
$mailboxes = get-mailbox -server mailserver
$total = $mailboxes.count
$count = 1
$mailboxes | sort-object -property displayname | foreach-object {
$percentcomplete = $count / $total * 100
write-progress -activity "message tracking log search" -status "please hold.....processing mailboxes" -percentcomplete $percentcomplete
$stats = "" | select-object name,sent,received
$email = $_.windowsemailaddress.tostring()
$stats.name = $_.displayname
$stats.sent = ($sent | where-object { ($_.eventid -eq "send") -and ($_.sender -eq $email) }).count
$results += $stats
$count += 1
}
$results | sort-object sent -descending | convertto-html -head $a –body "<h2>sent email</h2>" | out-file c:\scripts\emailsendrecievestats1.html
###create mail message , add statistics text file attachment
$smtpmessage = new-object system.net.mail.mailmessage $fromaddress, $toaddress, $messagesubject, $messagebody
$attachment = new-object net.mail.attachment ("c:\scripts\emailsendrecievestats1.html")
$smtpmessage.attachments.add($attachment)
###send message
$smtpclient = new-object system.net.mail.smtpclient $sendingserver
$smtpclient.send($smtpmessage)
run much, , see get:
$start = (get-date -hour 00 -minute 00 -second 00).adddays(-1)
$end = (get-date -hour 23 -minute 59 -second 59).adddays(-1)
$results = @()
$sent = get-messagetrackinglog -server anyserver -eventid send -start $start -end $end -resultsize unlimited
$over20 = $sent | group sender |? {$_.count -ge 20} | select count,name
$over20 | foreach-object {
if (get-mailbox $_.name){
$stats = "" | select-object name,sent
$stats.name = (get-mailbox $_.name).displayname
$stats.sent = $_.count
$results += $stats
}
}
$results
$start = (get-date -hour 00 -minute 00 -second 00).adddays(-1)
$end = (get-date -hour 23 -minute 59 -second 59).adddays(-1)
$results = @()
$sent = get-messagetrackinglog -server anyserver -eventid send -start $start -end $end -resultsize unlimited
$over20 = $sent | group sender |? {$_.count -ge 20} | select count,name
$over20 | foreach-object {
if (get-mailbox $_.name){
$stats = "" | select-object name,sent
$stats.name = (get-mailbox $_.name).displayname
$stats.sent = $_.count
$results += $stats
}
}
$results
Windows Server > Windows PowerShell
Comments
Post a Comment