How to get the Timer Job history

Source: Internet
Author: User

1. Get Timer JOB internal name with ID.

Job ID can is found in SharePoint CA.

Below PowerShell can help you retrieve all jobs ' Internal Name by keywords.

Get-sptimerjob | Sort-object name | where {$_. Name-like "*profile*"} | FT id,name

2. Using script in attachment, can get to the history of specific Timer Job

The result would be a like this.

PowerShell

$LogTime= Get-date-format yyyy-mm-dd_hh-mm$LogFile=". \timerjobreportpatch-$LogTime. rtf"   #Add SharePoint PowerShell Snapin   if((Get-pssnapin-name microsoft.sharepoint.powershell-erroraction silentlycontinue)-eq $null) {Add-PSSnapin Microsoft.SharePoint.Powershell}$scriptBase= Split-path$SCRIPT: Myinvocation. Mycommand.path-Parent Set-location$scriptBase   #Deleting any. rtf files in the scriptbase location$FindRTFFile= Get-childitem$scriptBase\*.*-include *. rtfif($FindRTFFile)   {       foreach($file inch $FindRTFFile) {Remove-item$file}} Start-transcript$logfile   FunctionTimerjobreport () {$Output=$scriptBase+"\"+"Timerjobreport.csv"; "Name"+","+"Status"+","+"Lastrun"+","+"Schedule"| Out-file-encodingDefault-filepath$Output; Write-host"generating timerjob Generic report"-Fore Yellow$TimerJobs= get-SPTimerJobforeach($TimerJob inch $Timerjobs)       {   $TimerJob. Name +","+$TimerJob. Status +","+$TimerJob. LastRunTime +","+$TimerJob. Schedule | Out-file-encodingDefault-append-filepath$Output; } Write-host"timerjob genric Report collected and placed under" $Output-Fore Green}Functiontimerjobhistory () {$Output 1=$scriptBase+"\"+"Timerjobhistoryreport.csv"; "Name"+","+"Status"+","+"ServerName"+","+"WebApplicationName"+","+"errormessage"| Out-file-encodingDefault-filepath$Output 1; Write-host"Generating timerjob History Report"-Fore Yellow$TimerJobs= get-SPTimerJobforeach($TimerJob inch $Timerjobs)       {           $JobHistories=$TimerJob. Historyentriesforeach($Jobhistory inch $JobHistories)           {               if($TimerJob. LastRunTime. ToUniversalTime ()-eq $JobHistory. StartTime) {   $TimerJob. Name +","+$Jobhistory. Status +","+$Jobhistory. ServerName +","+$Jobhistory. WebApplicationName +","+$Jobhistory. errormessage | Out-file-encodingDefault-append-filepath$Output 1; } }} write-host"timerjob History Report generated and placed under" $output 1-Fore Green}FunctionSpecifictimerjob () {$Output 2=$scriptBase+"\"+"Specifictimerjobhistoryreport.csv"; "Name"+","+"Status"+","+"ServerName"+","+"Timerjobstarttime"+","+"WebApplicationName"+","+"errormessage"| Out-file-encodingDefault-filepath$Output 2; $TimerJobName= Read-host"Enter the timer job name"       $Timerjob= Get-sptimerjob-identity$TimerJobName       $jobHistories= @($timerjob. Historyentries)$HowManyHistory= Read-host"Please enter the number of histories so want to return for this timerjob"        for($i= 0;$i -le $HowManyHistory;$i++)       {   $TimerJob. Name +","+$jobHistories[$i].status +","+$jobHistories[$i].servername +","+$jobHistories[$i]. StartTime +","+$jobHistories[$i]. WebApplicationName +","+$jobHistories[$i]. errormessage | Out-file-encodingDefault-append-filepath$Output 2; }           Break; } Write-host"########################################################################################################"-Fore Cyan Write-host"Enter 1 to get SP Timer job generic reports"-Fore Green Write-host"Enter 2 to get specific SP Timer job Report"-Fore Green Write-host"########################################################################################################"-Fore Cyan$option= Read-host"Enter the option"   Switch($option)   {       1{timerjobreport Timerjobhistory}2{Specifictimerjob}} write-host"SCRIPT completed"-Fore Green Stop-transcript

How to get the Timer Job history

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.