Run Health Analysis Jobs - Daily

Run all of the health analysis jobs which are scheduled to execute daily.

Really useful if you're developing a solution with many rules, and you want to execute them all.

After listing all of the jobs that are being executed, it outputs the current date/time... this helps when you want to be sure you ran it recently (say after the latest deployment).
Language:
PowerShell
Keywords:
SharePoint
Code Snippet

$tJobDefinitions = New-Object System.Collections.ArrayList

foreach ($tSvc in [Microsoft.SharePoint.Administration.SPFarm]::Local.Services)

{

    foreach ($tJobDef in $tSvc.JobDefinitions )

    {

        if ($tJobDef.DisplayName.StartsWith("Health Analysis Job") -and

            $tJobDef.DisplayName.Contains("Daily"))

        {

            $tJobDefinitions.Add($tJobDef) | Out-Null

        }

    }

}

 

foreach ($tJobDef in $tJobDefinitions)

{

    Write-Output $tJobDef.DisplayName

    $tJobDef.RunNow()

}

[System.DateTime]::Now


Created 2012-03-22
comments powered by Disqus
Login