Module was unable to convert parameter to a double value

Hi

Have made a custom Management Pack that uses a PS script to collect output.

I get this in the output (OpsMgr Eventlog on the agent running the workflow).

Module was unable to convert parameter to a double value
Original parameter: ‘$Data/Property[@Name=’LicensesTotal’]$’
Parameter after $Data replacement: ”
Error: 0x80020005
Details: Type mismatch.

I cant figure out what the fault is. If I runt the PS-script locally the output of LicensesTotal is shown.

Can anyone see if I’ve done something wrong in the below Collection rule?

Here is the Collection Rule:

<ManagementPackFragment SchemaVersion=”2.0″ xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<TypeDefinitions>
<ModuleTypes>
<DataSourceModuleType ID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses” Accessibility=”Internal” Batching=”false”>
<Configuration>
<xsd:element type=”xsd:integer” name=”IntervalSeconds” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID=”IntervalSeconds” Selector=”$Config/IntervalSeconds$” ParameterType=”int” />
</OverrideableParameters>
<ModuleImplementation Isolation=”Any”>
<Composite>
<MemberModules>
<DataSource ID=”Scheduler” TypeID=”System!System.Scheduler”>
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit=”Seconds”>$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates />
</Scheduler>
</DataSource>
<ProbeAction ID=”Probe” TypeID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses.Rule.ProbeActionModuleType”>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID=”Probe”>
<Node ID=”Scheduler” />
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>
<ProbeActionModuleType ID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses.Rule.ProbeActionModuleType” Accessibility=”Internal” Batching=”false” PassThrough=”false”>
<Configuration>
</Configuration>
<ModuleImplementation Isolation=”Any”>
<Composite>
<MemberModules>
<ProbeAction ID=”Probe” TypeID=”Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe”>
<ScriptName>TotalLicenses.ps1</ScriptName>
<ScriptBody>$IncludeFileContent/Scripts/TotalLicenses.ps1$</ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID=”Probe” />
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>
</ModuleTypes>
</TypeDefinitions>
<Monitoring>
<Rules>
<Rule ID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses.Rule” Comment=”Collects Total nr of Licenses” Enabled=”true” Target=”MWSR2!Microsoft.Windows.Server.2012.RemoteDesktopServicesRole.Service.RDLicensing” ConfirmDelivery=”false” Remotable=”true” Priority=”Normal” DiscardLevel=”100″>
<Category>PerformanceCollection</Category>
<DataSources>
<DataSource ID=”DataSource” TypeID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses”>
<IntervalSeconds>3600</IntervalSeconds>
</DataSource>
</DataSources>
<ConditionDetection ID=”System.Performance.DataGenericMapper” TypeID=”Perf!System.Performance.DataGenericMapper”>
<ObjectName>Remote Desktop Licensing</ObjectName>
<CounterName>Total Licenses</CounterName>
<InstanceName>ComputerName</InstanceName>
<Value>$Data/Property[@Name=’LicensesTotal’]$</Value>
</ConditionDetection>
<WriteActions>
<WriteAction ID=”Microsoft.SystemCenter.CollectPerformanceData” TypeID=”SC!Microsoft.SystemCenter.CollectPerformanceData” />
<WriteAction ID=”Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData” TypeID=”MSDL!Microsoft.SystemCenter.DataWarehouse.PublishPerformanceData” />
</WriteActions>
</Rule>
</Rules>
</Monitoring>
<LanguagePacks>
<LanguagePack ID=”ENU” IsDefault=”true”>
<DisplayStrings>
<DisplayString ElementID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses”>
<Name>Collects Total nr of Licenses Script</Name>
<Description>Collects Total nr of Licenses Script</Description>
</DisplayString>
<DisplayString ElementID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses.Rule.ProbeActionModuleType”>
<Name>Collects Total nr of Licenses Rule ProbeActionModuleType</Name>
<Description>Probe Action Module Type for Performance Rule: Collects Total nr of Licenses Rule</Description>
</DisplayString>
<DisplayString ElementID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses” SubElementID=”IntervalSeconds”>
<Name>Interval Seconds</Name>
</DisplayString>
<DisplayString ElementID=”PRS.Microsoft.Windows.Server.RemoteDesktopServices.2012.Extensions.TotalLicenses.Rule”>
<Name>Collects Total nr of Licenses</Name>
<Description>Collects Total nr of Licenses</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPackFragment>

2 Likes

I think we’ll need to see the script (or at least part of it). From the event log message, it looks like the LicensesTotal parameter is not returned. Is the property definitely added to the PropertyBag and the PropertyBag correctly returned from the script?

1 Like

Hi

Here is the script. If I run it locally it returns both $LicensesTotal and $TotalIssuedLicenses
However in SCOM (both monitor and perf rule) it doesn’t return any value for $LicensesTotal
Define Operations Manager objects ###
$momScriptAPI = new-object -comObject ‘MOM.ScriptAPI’
$propertyBag = $momScriptAPI.CreatePropertyBag();
Get total amount of licenses (2012 in this case)
$LicensesTotal = Get-WmiObject -Class Win32_TSLicenseKeyPack | where-object {$_.KeyPackId -eq “5”}
$LicensesTotal = $LicensesTotal.TotalLicenses

Get total number of issued 2008-licenses

$Used2008 = Get-WmiObject -Class Win32_TSLicenseKeyPack | where-object {$_.KeyPackId -eq “7”}
$Used2008 = $Used2008.IssuedLicenses

Get total number of issued 2012-licenses

$Used2012 = Get-WmiObject -Class Win32_TSLicenseKeyPack | where-object {$_.KeyPackId -eq “5”}
$Used2012 = $Used2012.IssuedLicenses

Lets do some math

$TotalIssuedLicenses = $Used2008 + $Used2012

 

If ($TotalIssuedLicenses -le $LicensesTotal ){

 

$propertyBag.AddValue(‘ScriptResult’,“GOOD”)

}

else {

 

$propertyBag.AddValue(‘ScriptResult’,“BAD”)

$propertyBag.AddValue(‘ErrorMessage’, “Antal utdelade licenser $TotalIssuedLicenses är mer än antal tillgängliga licenser $LicensesTotal”)

}

 

#Create Property Bag
$propertybag.AddValue(‘LicensesTotal’,$LicensesTotal)
$propertybag.AddValue(‘TotalIssuedLicenses’,$TotalIssuedLicenses)

 

 

 

#Return property bag
$propertybag

Add [double] in front of your $LicensesTotal and $TotalIssuesLicenses in your script.
It is possible that you are adding the value as a string value, which is why the performance rule is failing. Adding [double] in front of it when declaring the variable should fix that.

Br,

Jasper