Approved.System.Center.Operations.Manager.2016.Performance.Monitoring.GetSCOMMonitoringObject.PowerShell.Script.Perf.PA (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelector
TimeoutSecondsint$Config/TimeoutSeconds$

Source Code:

<ProbeActionModuleType ID="Approved.System.Center.Operations.Manager.2016.Performance.Monitoring.GetSCOMMonitoringObject.PowerShell.Script.Perf.PA" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>Approved.System.Center.Operations.Manager.2016.Performance.Monitoring.GetSCOMMonitoringObject.PowerShell.Script.Perf.PA.ps1</ScriptName>
<ScriptBody><Script>
#=================================================================================
# Description of Script here
#=================================================================================

#=================================================================================
# Constants section - modify stuff here:

# Assign script name variable for use in event logging
$ScriptName = "Approved.System.Center.Operations.Manager.2016.Performance.Monitoring.GetSCOMMonitoringObject.PowerShell.Script.Perf.PA.ps1"
#=================================================================================

# Gather script start time
$StartTime = Get-Date

# Gather who the script is running as
$whoami = whoami

# Load MOMScript API and Propertybag for output
$momapi = New-Object -comObject MOM.ScriptAPI

# Log an event for the script starting
$momapi.LogScriptEvent($ScriptName,1234,0, "Script is starting. Running, as ($whoami).")

# Main body of the script
#=================================================================================

# Any Arguments specified will be sent to the script as a single string.
# If you need to send multiple values, delimit them with a space, semicolon or other separator and then use split. param([string]$Arguments)

# Collect your performance counter here. Note that in order to support the DW this script MUST only return a single
# object/counter and those must be static values. You can return multiple instances just fine though.

Import-Module OperationsManager
New-SCOMManagementGroupConnection


$MeasureResult = Measure-Command {Get-SCOMMonitoringObject}
$Metric = $($$MeasureResult.TotalSeconds)
$Metric = ([math]::Round($Metric, 1))
$Instance = "Performance"



$PropertyBag = $momapi.CreatePropertyBag()
$PropertyBag.AddValue("Metric", $Metric)
$PropertyBag.AddValue("Instance",$Instance)

# Send output to SCOM

# End Main body of the script

#Log an event for script ending and total execution time.
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
$momapi.LogScriptEvent($ScriptName,1235,0,"Script has completed. Runtime was ($ScriptTime) seconds. Output value: ($Metric)")

#Output the propertybag
$PropertyBag
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>