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).
 
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.  
  Example 2
  In production, Krossfarm Administrator wants to disable all the timers  ContentDbsAreTooLarge, ReadOnlyDatabase and WindowsClassicTest, and wants to  enable the TimerRecycleFailed rule. 
- Get  
 - Let’ s disable all 3 Health rule one by one.  
 - $HR = Get - SPHealthAnalysisRuleContentDbsAreTooLarge  
 - Disable - SPHealthAnalysisRule $hr  
 - Get - SPHealthAnalysisRule $HR  
 
 Output will be like this  
  Now, repeat the above PowerShell command for other 2 rules. Run the below command for  ReadOnlyDatabase and WindowsClassicTest. 
- $HR = Get - SPHealthAnalysisRuleReadOnlyDatabase  
 - Disable - SPHealthAnalysisRule $hr  
 - Get - SPHealthAnalysisRule $HR  
 - and the same thing  
 - for WindowsClassicTest  
 - $HR = Get - SPHealthAnalysisRuleWindowsClassicTest  
 - Disable - SPHealthAnalysisRule $hr  
 - Get - SPHealthAnalysisRule $HR  
 
  Enable
  Now, we want to enable the Timer Job Health Rule. Use the following command for that. 
- $HR = Get - SPHealthAnalysisRuleTimerRecycleFailed  
 - Get - SPHealthAnalysisRule $HR  
 - Disable - SPHealthAnalysisRule $HR   
 - if ('this_is' == /an_example/) {  
 -     of_beautifier();  
 - } else {  
 -     var a = b ? (c % d) : e[f];  
 - }  
 
Output 
 
The Output will be Like this (you can see, the Enable status is True now)
.
![Scenario]()
![Scenario]()