onsdag den 10. april 2013

Disable all Health analyzer rules in SharePoint 2013


As in SharePoint 2010 we also in SharePoint 2013 have a lot of jobs running and analyzing the overall health of our server.  
All those rules are really nice, but in some cases you don’t need them. 
Example: 
  • If you know that you are running with databases over the limit and you are okay with that. 
  • You are running with only one service account, and is okay with that.
  • Your running whit a smaller page file than your physical RAM  (Quit a big file if you have 48Gb)

They all have in common that you as an admin made choices, and as we all know admins never make bad decisions. So instead of mannerly disable rules one at the time, you can just disable all and enable the ones you need.

To disable all rules just run the script below, this will disable all rules. To include the SharePoint SnapIn read this post  

If you like, this can be combined with a xml file so you can disable rules based on this as well. See this post to get inspiration. I would recommend using this if your maintaining a large organisation with a lot of environments.

PowerShell Script:
------------------------------
function main
{
$healthList = [Microsoft.SharePoint.Administration.Health.SPHealthRulesList]::Local.Items
 foreach ($Listitem in $healthList)
 {
  Write-Host -ForegroundColor Green $listitem.Id ": " -NoNewline
  if ($Listitem["HealthRuleCheckEnabled"] -ne $false)
  {
   Write-Host -ForegroundColor Magenta "Disable job"
   $Listitem["HealthRuleCheckEnabled"] = $false
   $Listitem.Update()
  }
  else
  {
   Write-Host -ForegroundColor White Done -BackgroundColor Black
  }
 }
}

Have fun with PowerShell 


Ingen kommentarer:

Send en kommentar