Check Running Timerjob Status using Powershell
Check the status of timer jobs that have been run by using Windows PowerShell.
$Job = Get-SPTimerjob "TimerJob Name"
[Array] $JobHistoryList=$Job.HistoryEntries
Start-SPTimerJob $Job
Write-Host "Running Timer Job" -NoNewline
$count = $JobHistoryList.count
$countNext = $count+1
while ( $countNext -ne $count)
{
[Array] $JobHistoryList=$Job.HistoryEntries
$count = $JobHistoryList.count
Write-Host "." -NoNewline
sleep 2
}
if ($taxonomyjob[0].status –ne "Succeeded")
{
Write-Host -f yellow $JobHistoryList[0].status
Write-Host -f yellow $JobHistoryList[0].ErrorMessage
}
else
{
Write-Host $JobHistoryList[0].status
}
$Job = Get-SPTimerjob "TimerJob Name"
[Array] $JobHistoryList=$Job.HistoryEntries
Start-SPTimerJob $Job
Write-Host "Running Timer Job" -NoNewline
$count = $JobHistoryList.count
$countNext = $count+1
while ( $countNext -ne $count)
{
[Array] $JobHistoryList=$Job.HistoryEntries
$count = $JobHistoryList.count
Write-Host "." -NoNewline
sleep 2
}
if ($taxonomyjob[0].status –ne "Succeeded")
{
Write-Host -f yellow $JobHistoryList[0].status
Write-Host -f yellow $JobHistoryList[0].ErrorMessage
}
else
{
Write-Host $JobHistoryList[0].status
}
Comments
Post a Comment