Exc15.Custom.Probe.CollectLoginLatency (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
Script ProbeAction Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Default

Source Code:

<ProbeActionModuleType ID="Exc15.Custom.Probe.CollectLoginLatency" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ServerName" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>LoginLatency.ps1</ScriptName>
<ScriptBody><Script>

param($serverName)

$api = New-Object -comObject 'MOM.ScriptAPI'
$api.LogScriptEvent('LoginLatency.ps1',1409,4,'connecting to ' + $servername)





Function Load-ExchangeSnapin
{
if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
}
Load-ExchangeSnapin



# Get the ExchangeServer object.
$exchangeServer = Get-ExchangeServer -Identity $serverName;
if ($exchangeServer -eq $null)
{
$message='Cannot find exchnage server'
$api.LogScriptEvent($EVENT_SOURCE,1403, 2, $message);


}


$count=0


$DBs=Get-MailboxDatabase -Server $serverName -Status
#|where {$_.Mounted -match 'true'}

foreach($DB in $DBs)
{
$latency=0

If ($DB.Mounted)
{
[int]$latency= (Test-MAPIConnectivity -Database $DB.identity.Name).Latency.Milliseconds

$message=' MBX DB= '+$DB.identity.Name+' count : ' + $Latency
$api.LogScriptEvent('LoginLatency.ps1',1409,4,$message)


$bag = $api.CreatePropertyBag()

$bag.AddValue('DatabaseName',$DB.identity.Name)
$bag.AddValue('Latency',$latency)
$bag

}
}


</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>serverName</Name>
<Value>$Config/ServerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>180</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>