---
updatedAt: 2025-08-14T13:33:26.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Windows Stability monitoring

```powershell PowerShell
#####################################################################################
# Script: WindowsStabilityIndex
# Description: Finds the most recent Windows Stability Index reading and places it
#              in the root\cimv2\Ncentral WMI namespace. This script is meant to be
#              used in conjunction with the Windows Stability Index custom service.
# Author: Chris Reid
# Date: Feb 10th, 2012
# Version: 1.0
#####################################################################################


# Version History

# 1.0 - Initial Release (Feb. 10th, 2012)



# Declare a few variables that we'll use later on in the script
$Namespace = "NCentral"
$Class = "WindowsStabilityIndex"



#Grab the most recent Stability Index reading from the Win32_ReliabilityStabilityMetrics WMI class. The Format-Table command hides the table headers - all this script needs is the value, not any of the surrounding text
$StabilityIndex = Get-Wmiobject Win32_ReliabilityStabilityMetrics -property @("SystemStabilityIndex") | Select-Object -first 1 {$_.SystemStabilityIndex} | Format-Table -HideTableHeaders | Out-String

# The first command gave an output that is a string value; we need to convert this to a decimal value before we drop it into WMI.
$StabilityIndex = [System.Convert]::ToDecimal($StabilityIndex)
write-host "The Stability Index is: " $StabilityIndex



# Check to see if the root\cimv2\Ncentral WMI namespace exists - if it doesn't, then let's create it
# Thanks to http://gallery.technet.microsoft.com/scriptcenter/d230c216-9d21-4130-a190-4049ca2df21c for the code
If (Get-WmiObject -Namespace "root\cimv2" -Class "__NAMESPACE" | Where-Object {$_.Name -eq $Namespace})
{
    WRITE-HOST "The root\cimv2\Ncentral WMI namespace exists."
}
Else
{
    WRITE-HOST "The root\cimv2\Ncentral WMI namespace does not exist."
    $wmi= [wmiclass]"root\cimv2:__Namespace"
    $newNamespace = $wmi.createInstance()
    $newNamespace.name = $Namespace
    $newNamespace.put()
}






# Check to see if the 'WindowsStabilityIndex' class exists - if it doesn't, then let's create it
If (Get-WmiObject -List -Namespace "root\cimv2\Ncentral" | Where-Object {$_.Name -eq $Class})
{
    WRITE-HOST "The " $Class " WMI class exists."
    # Because the class already exists, we need to make sure it's 'blank', and does not contain any pre-populated instances
    # Hint: Pre-populated instances could have come from someone having already run this script.
    $GetExistingInstances = Get-WmiObject -Namespace "root\cimv2\Ncentral" -Class $Class
	WRITE-HOST $GetExistingInstances
    If ($GetExistingInstances -eq $Null)
    {
        WRITE-HOST "There are no instances in this WMI class."
    }
    Else
    {
        WRITE-HOST "There are pre-existing instances of this WMI class - deleting."
        ForEach ($Instance in $GetExistingInstances) {Remove-WMIObject -Namespace "root\cimv2\Ncentral" -Class $Class}
    }
}

    WRITE-HOST "The " $Class " WMI class does need to be created."
    # Because the class doesn't exist (or has just been deleted), let's create it, and specify all of the appropriate properties.
    $subClass = New-Object System.Management.ManagementClass ("root\cimv2\Ncentral", [String]::Empty, $null);
    $subClass["__CLASS"] = $Class;
    $subClass.Qualifiers.Add("Static", $true)
    $subClass.Properties.Add("Name", [System.Management.CimType]::String, $false)
    $subClass.Properties["Name"].Qualifiers.Add("Key", $true)
    $subClass.Properties.Add("StabilityIndex", [System.Management.CimType]::Real64, $false)
    $subClass.Put()


# Now let's push the backup data into WMI
$PushDataToWMI = ([wmiclass]"root\cimv2\Ncentral:WindowsStabilityIndex").CreateInstance()
$PushDataToWMI.Name =  "Stability Data"
$PushDataToWMI.StabilityIndex = $StabilityIndex
$PushDataToWMI.Put()
```

```powershell Service Template
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>


<service xmlns="http://www.n-able.com" author="N-able SDK" creationdate="12/19/2011" organization="N-able Technologies" syntaxversion="1.1.0.0" version="1.0.0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


	<servicedefinition id="24168" reason="" releasedependency="4.5.0.0" servicetype="WMIWorkstation" version="1.0.0.6">
		<description country="ca" language="en">This script monitors the &#39;Stability Index&#39; of a Windows operating system. This custom service must be used in conjunction with the &#39;Windows Stability Index&#39; PowerShell script.</description>
		<displayname country="ca" language="en">Windows Stability</displayname>
		<displaylabel>Windows Stability</displaylabel>
		<help country="ca" language="en">Custom WMI Service</help>
		<popuphelp country="ca" language="en">Custom WMI Service</popuphelp>


		<serviceparameters aggregatedata="true" aggregatetasks="false" maxinstances="1" maxpollrate="59" minpollrate="1" schedulertype="Cron-like Scheduler" serviceinstancetype="Single" timetostale="10000"/>


		<moduleparameters>
			<moduleparameter key="scan_interval" max="1440" min="5" phardcoded="false" preferredident="false" type="String" value="0,5 0-23 * * *">
				<shortdescription country="ca" language="en">Scan Interval</shortdescription>
				<longdescription country="ca" language="en">Scan Interval</longdescription>
				<help country="ca" language="en">The number of minutes between scans.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.MatrixSize" max="" min="" phardcoded="true" preferredident="false" type="String" value="1">
				<shortdescription country="ca" language="en">Matrix Size</shortdescription>
				<longdescription country="ca" language="en">The number of matrices.</longdescription>
				<help country="ca" language="en">The number of matrices.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.0.NameSpace" max="" min="" phardcoded="true" preferredident="false" type="String" value="root\cimv2\Ncentral">
				<shortdescription country="ca" language="en">Namespace</shortdescription>
				<longdescription country="ca" language="en">WMI class namespace used for this scan detail.</longdescription>
				<help country="ca" language="en">WMI class namespace used for this scan detail.</help>
			</moduleparameter>
			<moduleparameter key="Matrix.0.ImpMethod" max="" min="" phardcoded="true" preferredident="false" type="String" value="Query">
				<shortdescription country="ca" language="en">Implementation Method</shortdescription>
				<longdescription country="ca" language="en">WMI implementation method used for this scan detail.</longdescription>
				<help country="ca" language="en">WMI implementation method used for this scan detail.</help>
			</moduleparameter>
			<moduleparameter key="Matrix.0.WMIClassName" max="" min="" phardcoded="true" preferredident="false" type="String" value="WindowsStabilityIndex">
				<shortdescription country="ca" language="en">Class Name</shortdescription>
				<longdescription country="ca" language="en">WMI class name used for this scan detail.</longdescription>
				<help country="ca" language="en">WMI class name used for this scan detail.</help>
			</moduleparameter>
			<moduleparameter key="Matrix.0.ProcessingType" max="" min="" phardcoded="true" preferredident="false" type="String" value="Value">
				<shortdescription country="ca" language="en">Processing Type</shortdescription>
				<longdescription country="ca" language="en">Processing type used for this scan detail.</longdescription>
				<help country="ca" language="en">Processing type used for this scan detail.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.0.ConstraintSize" max="" min="" phardcoded="true" preferredident="false" type="String" value="1">
				<shortdescription country="ca" language="en">Number of Constraints</shortdescription>
				<longdescription country="ca" language="en">The number of constraints for this scan detail.</longdescription>
				<help country="ca" language="en">The number of constraints for this scan detail.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.0.Constraint.0.Para" max="" min="" phardcoded="true" preferredident="false" type="String" value="Name">
				<shortdescription country="ca" language="en">Constraint 0</shortdescription>
				<longdescription country="ca" language="en">The constraint parameter for this scan detail.</longdescription>
				<help country="ca" language="en">The constraint parameter for this scan detail.</help>
				<presentationinfo>
					<presentationitem datatype="String" description="" type="mandatory" value="" />
				</presentationinfo>
			</moduleparameter>
			<moduleparameter key="Matrix.0.Constraint.0.Value" max="" min="" phardcoded="true" preferredident="false" type="String" value="Stability Data">
				<shortdescription country="ca" language="en">WMI property</shortdescription>
				<longdescription country="ca" language="en">The name of the variable used for this scan detail.</longdescription>
				<help country="ca" language="en">Enter the WMI property to be used by this service.</help>
				<presentationinfo>
					<presentationitem datatype="String" description="" type="mandatory" value="" />
				</presentationinfo>
			</moduleparameter>
			<moduleparameter key="Matrix.0.Constraint.0.Type" max="" min="" phardcoded="true" preferredident="false" type="String" value="AND">
				<shortdescription country="ca" language="en"/>
				<longdescription country="ca" language="en"/>
				<help country="ca" language="en"/>
			</moduleparameter>
			<moduleparameter key="Matrix.0.Constraint.0.PaddingType" max="" min="" phardcoded="true" preferredident="false" type="String" value="PathAndQuotes">
				<shortdescription country="ca" language="en">Padding Type</shortdescription>
				<longdescription country="ca" language="en">Padding type used to construct WQL query.</longdescription>
				<help country="ca" language="en">Padding type used to construct WQL query.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.0.VarSize" max="" min="" phardcoded="true" preferredident="false" type="String" value="1">
				<shortdescription country="ca" language="en">Number of Variables</shortdescription>
				<longdescription country="ca" language="en">The number of variables for this scan detail.</longdescription>
				<help country="ca" language="en">The number of variables for this scan detail.</help>
			</moduleparameter>



			<moduleparameter key="Matrix.0.Var.0.Property" max="" min="" phardcoded="true" preferredident="false" type="String" value="StabilityIndex">
				<shortdescription country="ca" language="en">Property 0</shortdescription>
				<longdescription country="ca" language="en">The WMI property used for this scan detail.</longdescription>
				<help country="ca" language="en">The WMI property used for this scan detail.</help>
			</moduleparameter>
			<moduleparameter key="Matrix.0.Var.0.VarName" max="" min="" phardcoded="true" preferredident="false" type="String" value="StabilityIndex.WindowsStabilityIndex">
				<shortdescription country="ca" language="en">Variable 0 Name</shortdescription>
				<longdescription country="ca" language="en">The name of the variable used for this scan detail.</longdescription>
				<help country="ca" language="en">The name of the variable used for this scan detail.</help>
			</moduleparameter>



			<moduleparameter key="Scandetail.Size" max="" min="" phardcoded="true" preferredident="false" type="String" value="1">
				<shortdescription country="ca" language="en"/>
				<longdescription country="ca" language="en"/>
				<help country="ca" language="en"/>
			</moduleparameter>



			<moduleparameter key="Scandetail.0.Name" max="" min="" phardcoded="true" preferredident="false" type="String" value="WMI24168_1">
				<shortdescription country="ca" language="en">Scan detail name</shortdescription>
				<longdescription country="ca" language="en">Scan detail name</longdescription>
				<help country="ca" language="en">Scan detail name</help>
			</moduleparameter>
			<moduleparameter key="Scandetail.0.Recipe" max="" min="" phardcoded="true" preferredident="false" type="String" value="$StabilityIndex.WindowsStabilityIndex">
				<shortdescription country="ca" language="en">Scan detail recipe</shortdescription>
				<longdescription country="ca" language="en">Scan detail recipe</longdescription>
				<help country="ca" language="en">Scan detail recipe</help>
			</moduleparameter>
			<moduleparameter key="Scandetail.0.Type" max="" min="" phardcoded="true" preferredident="false" type="String" value="FLOAT">
				<shortdescription country="ca" language="en">Scan detail type</shortdescription>
				<longdescription country="ca" language="en">Scan detail type</longdescription>
				<help country="ca" language="en">Scan detail type</help>
			</moduleparameter>

		</moduleparameters>



		<scandetails>
			<scandetailid>2416801</scandetailid>
		</scandetails>
	</servicedefinition>



	<scandetail id="2416801" monitoringtypeon="true" processforstate="true" releasedependency="4.5.0.0" version="1.0.0.2" >
		<thresholddefaults>
			<thresholds configurable="true" type="Float">
				<threshold high="10" low="7" state="Normal"/>
				<threshold high="6" low="5" state="Warning"/>
				<threshold high="4" low="0" state="Failed"/>
			</thresholds>
		</thresholddefaults>
		<description country="ca" language="en">Stability Index</description>
		<help country="ca" language="en">Help</help>
		<popuphelp country="ca" language="en">Popup Help</popuphelp>
		<displayname country="ca" language="en">WMI24168_1</displayname>
	</scandetail>
</service>
<?N-able-SDK version=3.0?>
```

```json Response Example
{"success":true}
```

# Windows Stability monitoring



There are a few steps involved in getting this service to work:

1. Upload the custom service to your N-central server (instructions on how to do this are included in this Zip file)

2. Run the included PowerShell (*.ps1) script on the appropriate Windows devices
(Recommend doing this through a Scheduled Task Profile in N-central)

3. Adding the custom service to the appropriate devices in N-central (Recommend putting the custom service into a Service Template, and then associating both the Service Template and the Scheduled Task Profile with a Rule)