惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
罗磊的独立博客
人人都是产品经理
人人都是产品经理
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
L
Lohrmann on Cybersecurity
博客园 - 【当耐特】
量子位
Last Week in AI
Last Week in AI
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Cyber Attacks, Cyber Crime and Cyber Security
腾讯CDC
有赞技术团队
有赞技术团队
Cyberwarzone
Cyberwarzone
T
Tor Project blog
V
V2EX
L
LINUX DO - 热门话题
Security Latest
Security Latest
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
NISL@THU
NISL@THU
C
Cisco Blogs
T
Tailwind CSS Blog
G
GRAHAM CLULEY
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
小众软件
小众软件
K
Kaspersky official blog
博客园 - 司徒正美
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
S
Schneier on Security
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
Scott Helme
Scott Helme
J
Java Code Geeks
博客园 - 聂微东
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
AWS News Blog
AWS News Blog
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
F
Fortinet All Blogs
T
Threat Research - Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网

博客园 - 努力学习的小熊

SharePoint - Another Way to Delete Site Collection Exchange - Add Owner of Distribution Group Exchange Online Mailbox Restoration OUTLOOK - Unable to Delete Meetings Outlook Error: The Delegates settings were not saved correctly. Cannot activate send-on-behalf-of list. Office365 OneDrive Geo Move SharePoint Excel Service - Couldn't Open the Workbook. User Get 'Access Denied' with Excel Service WebPart How To Search and Restore files from Site Collection Recycle Bin How To Collect ULS Log from SharePoint Farm How To Restart timer service on all servers in farm How to Operate SharePoint User Alerts with PowerShell Synchronization Service Manager SharePoint 2007 Full Text Searching PowerShell and CS file content with SharePoint Search 0x80040E14 Caused by Max Url Length bug SharePoint 2007 User Re-created in AD with new SID issue on MySite SharePoint 2007 Prompt for Credentials When Accessing FQDN Sites From a Windows Vista or Windows 7 Computer SharePoint 2010 找回丢失的Social Collaboration Web Parts SharePoint 客户端经常弹出Windows验证登录框问题
How to get Timer Job History
努力学习的小熊 · 2015-11-12 · via 博客园 - 努力学习的小熊

2015-11-12 10:11  努力学习的小熊  阅读(531)  评论()    收藏  举报

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