SPHealthRulesList class

Represents a list of SharePoint Health Analyzer rule definitions registered with the farm.

Inheritance hierarchy


Namespace:  Microsoft.SharePoint.Administration.Health
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)


<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPHealthRulesList _
    Inherits SPList _
    Implements IDisposable
Dim instance As SPHealthRulesList
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPHealthRulesList : SPList, 


This class represents the Health Rules list in the Monitoring section of Central Administration. A farm administrator can use the Health Rules list to edit the settings for a health rule, changing where or when the rule runs, or even disabling the rule altogether.

To get an instance of the SPHealthRulesList class, access the static Local property. Once you have SPHealthRulesList object, you can query the list as you would any SPList object.


The SPHealthRulesList object returned by the Local property uses unmanaged resources. You are responsible for releasing those resources. One way to do that is to call the Dispose() method when you no longer need the object.


The following example is a console application that prints the title and schedule for every rule in the Health Rules list for the farm. Note that in order to access the Health Rules list, the local server must be joined to the farm.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Administration.Health;

namespace Test
    class Program
        static void Main(string[] args)
            if (SPFarm.Joined)
                using (SPHealthRulesList list = SPHealthRulesList.Local)
                    // Get a collection of rule definitions in alphabetical order.
                    SPQuery query = new SPQuery();
                    query.Query = "<OrderBy><FieldRef Name=\"LinkTitleNoMenu\" /></OrderBy>";
                    SPListItemCollection rules = list.GetItems(query);

                    // Print the title and schedule for each item.
                    foreach (SPListItem rule in rules)
                        Console.WriteLine("\n{0} Runs: {1}",
            Console.Write("\nPress ENTER to continue...");
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration
Imports Microsoft.SharePoint.Administration.Health

Module Test

    Sub Main()

        If SPFarm.Joined Then

            Using list As SPHealthRulesList = SPHealthRulesList.Local

                ' Get a collection of rule definitions in alphabetical order.
                Dim query As SPQuery = New SPQuery()
                query.Query = "<OrderBy><FieldRef Name='LinkTitleNoMenu' /></OrderBy>"
                Dim rules As SPListItemCollection = list.GetItems(query)

                ' Print the title, date, and status for each item.
                Dim rule As SPListItem
                For Each rule In rules
                    Console.WriteLine(vbCrLf + "{0} Runs: {1}", _
                            rule(SPBuiltInFieldId.LinkTitleNoMenu).ToString(), _

            End Using
        End If
        Console.Write(vbCrLf + "Press ENTER to continue...")
    End Sub

End Module

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also


SPHealthRulesList members

Microsoft.SharePoint.Administration.Health namespace


Other resources

Working with SharePoint Maintenance Manager