Managing Health Analysis Rules In SharePoint 2016

This article is a sequence of real world examples of using PowerShell in SharePoint 2016. In this article, we will discuss how we can use the PowerShell cmdlets for managing the Health Analysis rule in SharePoint. We will try to cover all the available cmdlets i.e. get, enable, and disable.

Scenario

KrossFarm administrators are having some known issues with their environment but certain Health Analysis Rule is annoying the most. So, they want to disable all rules in the lower environment (dev farms) and disable certain rules in the Production Farm. Also, they found that one of the Health Rules (TimerRecycleFailed) is already disabled in the Production Farm, which they want to enable.

Tasks

  • Get the Health Analysis Rule
  • Disable all Rules in Dev and few in Production
  • Enable the Timer Job rule in Prod.

I have splitted the scenario into 2 examples. In the 1st example, I will work in Dev farm and disable all the health rules, while in 2nd example, I will disable a couple of rules and enable 1 rule in Production.

Example 1

Let’s start with Dev farm.

Get

First, we will list all health rules in the farm. For that, we will run this command

Get-SPHealthAnalysisRule


You will get the output like this. it includes Name, ID, Enabled Status, Category, and Summary of all rules.

You can write them in a Text file for better understanding.



Disable

Now, we want to disable all Health Analysis rules.

Get-SPHealthAnalysisRule | Disable-SPHealthAnalysisRule

This command will get the Health Rules and disable them one by one. It asks you for the confirmation and if you press “Y”, it will repeat the process for all individual rules. But, if you type “A”, that means you said “Yes to All” ( as I did).

Scenario
 
Now, if we want to check the status of the rules, then we have to re-run the get command.

If you run the below get command, then you will see the status of the rules.

Get-SPHealthAnalysisRule | select name enabled

You will see "Enabled" is "False" for all rules.

Scenario

Example 2

In production, Krossfarm Administrator wants to disable all the timers  ContentDbsAreTooLarge, ReadOnlyDatabase and WindowsClassicTest, and wants to enable the TimerRecycleFailed rule.
  1. Get  
  2. Let’ s disable all 3 Health rule one by one.  
  3. $HR = Get - SPHealthAnalysisRuleContentDbsAreTooLarge  
  4. Disable - SPHealthAnalysisRule $hr  
  5. Get - SPHealthAnalysisRule $HR  
Output will be like this

Scenario

Now, repeat the above PowerShell command for other 2 rules. Run the below command for ReadOnlyDatabase and WindowsClassicTest.
  1. $HR = Get - SPHealthAnalysisRuleReadOnlyDatabase  
  2. Disable - SPHealthAnalysisRule $hr  
  3. Get - SPHealthAnalysisRule $HR  
  4. and the same thing  
  5. for WindowsClassicTest  
  6. $HR = Get - SPHealthAnalysisRuleWindowsClassicTest  
  7. Disable - SPHealthAnalysisRule $hr  
  8. Get - SPHealthAnalysisRule $HR  
Enable

Now, we want to enable the Timer Job Health Rule. Use the following command for that.
  1. $HR = Get - SPHealthAnalysisRuleTimerRecycleFailed  
  2. Get - SPHealthAnalysisRule $HR  
  3. Disable - SPHealthAnalysisRule $HR // This is just a sample script. Paste your real code (javascript or HTML) here.  
  4. if ('this_is' == /an_example/) {  
  5.     of_beautifier();  
  6. else {  
  7.     var a = b ? (c % d) : e[f];  
  8. }  
Output 
 
The Output will be Like this (you can see, the Enable status is True now).

Scenario

Scenario

 

Up Next
    Ebook Download
    View all
    Learn
    View all