How to get Timer Job History
2015-11-12 10:11 努力学习的小熊 阅读(491) 评论(0) 编辑 收藏 举报1. Get Timer Job internal name with id.
Job ID can be 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, you can get the history of specific Timer Job
The result will be 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 *.rtf if($FindRTFFile) { foreach($file in $FindRTFFile) { remove-item $file } } start-transcript $logfile Function TimerJobReport() { $Output = $scriptBase + "\" + "TimerJobReport.csv"; "Name" + "," + "Status" + "," + "LastRun" + "," + "Schedule" | Out-File -Encoding Default -FilePath $Output; write-host "Generating TimerJob generic report" -fore yellow $TimerJobs = get-sptimerjob foreach($TimerJob in $Timerjobs) { $TimerJob.name + "," + $TimerJob.status + "," + $TimerJob.lastruntime + "," + $TimerJob.schedule | Out-File -Encoding Default -Append -FilePath $Output; } write-host "TimerJob genric report collected and placed under " $Output -fore green } Function TimerJobHistory() { $Output1 = $scriptBase + "\" + "TimerJobHistoryReport.csv"; "Name" + "," + "Status" + "," + "ServerName" + "," + "WebApplicationName" + "," + "ErrorMessage" | Out-File -Encoding Default -FilePath $Output1; write-host "Generating TimerJob history report" -fore yellow $TimerJobs = get-sptimerjob foreach($TimerJob in $Timerjobs) { $JobHistories = $TimerJob.historyentries foreach($Jobhistory in $JobHistories) { if($TimerJob.lastruntime.ToUniversalTime() -eq $JobHistory.starttime) { $TimerJob.Name + "," + $Jobhistory.status + "," + $Jobhistory.servername + "," + $Jobhistory.WebApplicationName + "," + $Jobhistory.ErrorMessage | Out-File -Encoding Default -Append -FilePath $Output1; } } } write-host "TimerJob history report generated and placed under " $output1 -fore green } Function SpecificTimerJob() { $Output2 = $scriptBase + "\" + "SpecificTimerJobHistoryReport.csv"; "Name" + "," + "Status" + "," + "ServerName" + "," + "TimerJobStartTime" + "," + "WebApplicationName" + "," + "ErrorMessage" | Out-File -Encoding Default -FilePath $Output2; $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 that you 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 -Encoding Default -Append -FilePath $Output2; } 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
2008-11-12 Building Document Workflows in SharePoint 2007 翻译