Getting Current Health Analyzer Alerts with PowerShell

Recently while working on a SharePoint monitoring PowerShell script we stumbled across the need to output the results of SharePoint’s Health Analyzer using PowerShell. Perhaps not most commonly needed functionality but we think it has some neat applications.

After a little bit of digging online and not finding anything we dove into Central Admin and discovered that in fact the Health Analyzer is simply a modified SharePoint task list in the Central Admin site. The list contains an item for each possible rule that can be triggered. The default view filters to only show items that don’t have a value of “4 – Success” in the Severity column. The list itself is actually called “Review Problems and Solutions”. All of that led to the following PowerShell script:

[powershell]
$centralAdminURL = "<central admin URL complete with port>"
$listName = "Review Problems and Solutions"
$spSourceWeb = Get-SPWeb $centralAdminURL
$spSourceList = $spSourceWeb.Lists[$listName]
$spSourceItems = $spSourceList.GetItems() | where {$_['Severity'] -ne "4 - Success"}
$spSourceItems | ForEach-Object {
   Write-Host $_['Title']
   }
[/powershell]

This script should be run in the SharePoint Management Shell.

Please note: Scripts in this blog are provided as is with “no-warranties”. They should be run by admins with a knowledge of the systems that will be affected.