Force Run SharePoint Health Analyzer Jobs on Demand using PowerShell

We may want to run SharePoint health analyzer on-demand to check if everything is alright in the farm, without waiting for them to run automatically. Well, as discussed in my another article, Run SharePoint 2010 Timer Jobs On-Demand with PowerShell , we can force run SharePoint Health Analyzer timer Jobs on Demand with PowerShell!

How to run SharePoint 2010/2013 health analyzer with PowerShell:
Lets use PowerShell to force run health analyzer jobs. Here is the PowerShell to rerun health analyzer
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Display name of the Timer Job to Run on-demand
$TimerJobName = "Health Analysis Job"
#Get the Timer Job
$TimerJobs = Get-SPTimerJob | where { $_.DisplayName -match $TimerJobName}

foreach($TimerJob in $TimerJobs) 
    Write-Host "Running:" $TimerJob.DisplayName
This script executes all timer jobs with "Health Analysis Job" in its display name which performs health check immediately!
Run SharePoint 2013 Health Analyzer Jobs on Demand

One Liner to SharePoint 2013 run all health analyzer:
Get-SPTimerJob | where { $_.DisplayName -match "Health Analysis Job"} | % { Start-SPTimerJob $_ ; Write-Host "Runing Job:" $_.displayName } # 

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.