当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

作者:精品下载站 日期:2024-12-14 14:04:13 浏览:16 分类:玩电脑

使用 PowerShell 获取 SharePoint 计时器作业历史记录


要求:检索并查看 SharePoint 计时器作业历史记录以解决问题。

如何在 SharePoint 中获取计时器作业历史记录?

SharePoint 2013 管理中心网站提供了一个获取计时器作业历史记录的界面。以下是在 SharePoint 中获取 SharePoint 计时器作业历史记录的步骤。

  • 导航到 SharePoint 2013 管理中心网站
  • 转到监控>>检查作业状态

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

  • 单击左侧导航中的“工作历史记录”链接

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

  • 在“查看”过滤器下,选择“作业定义”。一旦您选择“查看过滤器”作为“作业定义”,您会发现级联过滤器显示为“作业定义”。您还可以选择以下选项:服务、Web 应用程序、服务器。

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

  • 单击职位定义过滤器以“更改职位定义”

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

  • 选择相关的计时器作业定义。例如。审计日志修剪、即时警报等

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

  • 现在,您将找到所选计时器作业的作业历史记录,如下所示。

    [玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

PowerShell 用于搜索和导出特定时间段的计时器作业历史记录:

为什么选择 PowerShell?好吧,上面的中央管理页面提供了分析与特定作业或服务相关的计时器作业的界面,但是除了逐页导航之外,没有任何简单的方法可以获取特定时间段的计时器作业历史记录。因此,让我们使用 PowerShell 脚本来查找并提取计时器作业历史记录。

获取网络应用程序的所有计时器作业:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
# Variables
$WebAppURL = "https://intranet.crescent.com" 
$StartTime = "09/26/2015 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "09/26/2015 01:30:00 AM"

#Get all timer jobs associated with a web application
$WebApp = Get-SPWebApplication $WebAppURL

$Results = $WebApp.JobHistoryEntries | 
      where { ($_.StartTime -ge  $StartTime) -and ($_.EndTime -le $EndTime) } | 
          Select JobDefinitionTitle,WebApplicationName,ServerName,Status,StartTime,EndTime

#Send results to Grid view    
$Results | Out-GridView

SharePoint PowerShell 获取计时器作业历史记录:获取特定计时器作业的计时器作业历史记录


# Variables
$StartTime = "09/26/2015 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "09/26/2015 01:30:00 AM"
$TimerJobName = "Immediate Alerts"

#To Get Yesterday's use:
#$StartDateTime = (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') + " 00:00:00" 
#$EndDateTime   = (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') + " 23:59:59"

#Get the specific Timer job
$Timerjob = Get-SPTimerJob | where { $_.DisplayName -eq $TimerJobName } 

#Get all timer job history from the web application
$Results = $Timerjob.HistoryEntries  | 
      where { ($_.StartTime -ge  $StartTime) -and ($_.EndTime -le $EndTime) } | 
          Select WebApplicationName,ServerName,Status,StartTime,EndTime

#Send results to Grid view    
$Results | Out-GridView

使用 PowerShell 的 SharePoint 计时器作业历史记录:失败的计时器作业历史记录报告


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
# Variables
$WebAppURL = "https://intranet.crescent.com" 
$StartTime = "01/01/2016 01:00:00 AM"  # mm/dd/yyyy hh:mm:ss
$EndTime = "05/01/2016 01:30:00 AM"
$OutPutFile="D:\FailedJobHistoryRpt.csv"

#Get all timer jobs associated with a web application
$WebApp = Get-SPWebApplication $WebAppURL

#Get all Failed Timer jobs in between given Time
$Results = $WebApp.JobHistoryEntries | Where {($_.StartTime -ge $StartTime) -and ($_.EndTime -le $EndTime) -and ($_.Status -ne 'Succeeded')} 

#Export to CSV
$Results | Export-Csv $OutPutFile -NoType

write-host "Failed Timer jobs history Exported to CSV!" -F Green

和输出报告:

[玩转系统] 使用 PowerShell 获取 SharePoint 计时器作业历史记录

此 CSV 为您提供了一种快速分析计时器作业历史记录的方法。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯