Exchange 2010 Powershell指令碼攻略(十一)

ImSunkist發表於2011-07-12

ConvertTo-MessageLatency

param(

[Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent] $MessageTrackingEvent

)

begin

{

# PrintLatencies

function PrintLatencies

{

param(

[Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent] $mte = $(throw "argument is mandatory")

)

# Get latency objects from the event.

$latencies = [Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingLatency]::GetLatencies($mte)

# Print each latency component.

foreach ($latency in $latencies)

{

$latency

}

}

# Print usage information

function Usage

{

@"

NAME

ConvertTo-MessageLatency

SYNOPSIS

ConvertTo-MessageLatency -MessageTrackingEvent MessageTrackingEvent

SHORT DESCRIPTION

The ConvertTo-MessageLatency command gets retrieves component latency details from a message tracking event.

DETAILED DESCRIPTION

Parameters:

-MessageTrackingEvent MessageTrackingEvent

[Microsoft.Exchange.Management.TransportLogSearchTasks.MessageTrackingEvent]

[pipeline input allowed]

A message tracking log event object.

---

ConvertTo-MessageLatency reads the MessageInfo, MessageLatency, and LatencyType properties

from the MessageTrackingEvent object specified and writes a collection of MessageTrackingLatency objects to the pipeline.

This command also supports the ubiquitous parameters:

-Debug (-db), -ErrorAction (-ea), -ErrorVariable (-ev), -WarningAction (-wa), -WarningVariable (-wv),

-OutputBuffer (-ob), -OutputVariable (-ov), and -Verbose (-vb)

NOTES

TBD

EXAMPLES

Get-MessageTrackingLog | ConvertTo-MessageLatency

Output: a collection of MessageTrackingLatency objects that will contain combination of message-specific properties and component latencies

Get-MessageTrackingLog -EventId:扴END?-Start:'5/4/2007 2:09:20 PM' -End:'5/4/2007 3:09:20 PM' | where {$_.MessageLatency.TotalSeconds -gt 90} | ConvertTo-MessageLatency | where {$_.ComponentCode -eq 慟D?-and $_.ComponentLatency.TotalSeconds -gt 30} | fl MessageId,ServerIp,MessageLatency,ComponentLatency

"@

}

}

process

{

# process pipelined tracking events.

if ($_ -ne $null)

{

PrintLatencies $_

}

}

end

{

# check for Usage Statement request

if (($args.Count -gt 0) -and ($args[0] -imatch "-{1,2}[?h]"))

{

# user wants the usage statement

Usage

return

}

# if a tracking event was passed in as an argument, process it.

if ($MessageTrackingEvent -ne $null)

{

PrintLatencies $MessageTrackingEvent

}

}

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23700676/viewspace-1052337/,如需轉載,請註明出處,否則將追究法律責任。

相關文章