Run SharePoint’s health rules immediately with PowerShell

Instead of waiting for every health rule’s timer job to run on its own, it’s also possible to run them manually. The following script will execute every timer job with “Health Analysis Job” in its display name.

First we have to check whether or not the PowerShell snap-in is loaded, and if it’s not, load it.

if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
    Add-PsSnapin Microsoft.SharePoint.PowerShell
}

$healthRules = Get-SPTimerJob | Where {$_.DisplayName -match "Health Analysis Job"}
foreach($healthRule in $healthRules) {
    Write-Host "Executing" . $healthRule.DisplayName
    $healthRule.RunNow()
}

Now quickly go fix those errors!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s