Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SPHealthRulesList.Local Property

Gets an SPHealthRulesList object that represents the SharePoint Health Analyzer Rules list for the farm.

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

'Declaration
Public Shared ReadOnly Property Local As SPHealthRulesList
	Get
'Usage
Dim value As SPHealthRulesList

value = SPHealthRulesList.Local

Property Value

Type: Microsoft.SharePoint.Administration.Health.SPHealthRulesList
An SPHealthRulesList object that represents the SharePoint Health Analyzer Rules list for the farm.

ExceptionCondition
InvalidOperationException

The local server is not joined to the farm.

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 SPHealthRulesList object.

The following example is a console application that queries the Health Rules list for rules that are capable of automatically repairing the problem that the rule is designed to detect. The example enumerates the result set, printing the display text and schedule for each rule to the console.

Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration.Health

Module Test

    Sub Main()

        Using definitions As SPHealthRulesList = SPHealthRulesList.Local
            If Not definitions Is Nothing Then

                ' Write a query to find auto-repair rules.
                Dim query As SPQuery = New SPQuery()
                query.Query = "<Where><Eq>"
                query.Query += "<FieldRef Name='HealthRuleAutoRepairEnabled' />"
                query.Query += "<Value Type='Boolean'>1</Value>"
                query.Query += "</Eq></Where>"

                ' Retrieve list items that satisfy the query.
                Dim rules As SPListItemCollection = definitions.GetItems(query)

                ' Print the title and schedule for each item.
                Dim rule As SPListItem
                For Each rule In rules
                    Console.WriteLine("{0,-70} {1}", _
                        rule(SPBuiltInFieldId.LinkTitleNoMenu).ToString(), _
                        rule(SPBuiltInFieldId.HealthRuleSchedule).ToString())
                Next

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

End Module
Show:
© 2015 Microsoft