header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Message tracking & measure-object
Last Post 01 Aug 2010 10:43 AM by 0ptikGhost. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
RyanUser is Offline
New Member
New Member
Posts:1
Avatar

--
28 Jul 2010 09:16 PM
    Hi There,
    I have recently created a message tracking script to do the following:
    1. Retrieve all message tracking data for a 24 hour period
    2. Group all senders in the logs using group-object
    3. Calculate the total sum of email sent by each sender

    All works well, took me a little while to put it together, but think i have the correct syntax.
    Only problem is that it can take many many many hours to perform the calculation.

    I work for a large organization that heavily uses email, each 24 hour period returns about 5000 individual users who have sent email in that time.
    I would love to see any ideas on how I could possibly speed this up?

    So here is the cmdlets:

    1. to retrieve the message tracking logs ---

    $sendersbyvolume = Get-ExchangeServer | where {$_.isHubTransportServer -eq $true} | get-messagetrackinglog -eventid "deliver" -Start "27/07/2010 12:00:00 am" -End  "27/07/2010 11:59:59 pm" -ResultSize Unlimited  | Select-Object Timestamp, Sender, {$_.recipients}, messagesubject, totalbytes


    2. Now group the senders

    $groupedsenders = $sendersbyvolume | Group-Object -Property sender | select name

    3. Now measure and sum totalbytes for each sender, then set to (KB)

    $output = ForEach ($obj in $groupedsenders) { $sendersbyvolume | where {$_.sender -eq $obj.name } | measure -Property totalbytes -Sum | select @{n="User";e={$obj.name -join ","}}, @{n="TotalItemSize(KB)";e={$_.Sum / 1KB}}}

    4. Now round off to two decimal places and select top 25 senders

    $Output | select User, @{n="TotalItemSize(KB)";expression={[System.Math]::Round($_."TotalItemSize(KB)", 2)}} | sort'TotalItemSize(KB)' -Descending | select -First 25


    cheers




    0ptikGhostUser is Offline
    Basic Member
    Basic Member
    Posts:296
    Avatar

    --
    01 Aug 2010 10:43 AM

    By assigning temporary results into variables you are creating large arrays that must then be enumerated in the next stage of the processing. This _might_ be causing timing issues as you need to collect all the items generated thus far before continuing. I propose a longer pipeline where the collection happens at the very end when it is necessary (at group and sort time). I don't know how much speed up that will provide but it should help some.

    I also noticed that you were selecting properties that were not used. I don't think this will have too much of an effect on the execution time but we might as well not select those properties as they are not used.

    Get-ExchangeServer | Where-Object -Filter { $_.isHubTransportServer } | Get-MessageTrackingLog -EventId Deliver -Start '27/07/2010 12:00:00 am' -End '27/07/2010 11:59:59 pm' -ResultSize Unlimited | Select-Object -Property Sender, TotalBytes | Group-Object -Property Sender | Select-Object -Property @( @{ Name = 'User' ; Expression = { $_.Name } }, @{ Name = 'TotalItemSize(KB)' ; Expression = { [System.Math::Round(($_.Group | Measure-Object -Property TotalBytes -Sum).Sum / 1KB, 2) } } ) | Sort-Object -Property 'TotalItemSize(KB)' -Descending | Select-Object -First 25
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer