เปิด-ปิดการใช้งานตัวจับเวลาโดยใช้ PowerShell ใน SharePoint
งานตัวจับเวลาทำงานเฉพาะใน SharePoint ผ่านบริการ Windows Timer เช่น การส่งการแจ้งเตือนทางอีเมลตามเวลาที่กำหนด ในไซต์การดูแลจากศูนย์กลางของ SharePoint คุณสามารถตรวจสอบงานตัวจับเวลา ปิดใช้งานหรือเปิดใช้งานงานตัวจับเวลาเฉพาะได้
สคริปต์ PowerShell เพื่อตรวจสอบสถานะงานตัวจับเวลา:
#Function to Check Timer job status
Function Get-TimerJobStatus($TimerJobName)
{
$TimerJob = Get-SPTimerJob | Where-Object { $_.displayname -like $TimerJobName }
if($TimerJob -eq $null)
{
Write-host "Timer job not found!" -ForegroundColor Red
return
}
$TimerJobDisabled = $TimerJob | Select -ExpandProperty IsDisabled
if($TimerJobDisabled)
{
Write-host "Timer Job is Disabled!" -ForegroundColor Yellow
}
else
{
Write-host "Timer Job is Enabled!" -ForegroundColor Green
}
}
$TimerJobName="My Site Cleanup Job"
Get-TimerJobStatus $TimerJobName
จะปิดการใช้งานตัวจับเวลาใน SharePoint ได้อย่างไร
หากต้องการปิดใช้งานงานตัวจับเวลา ให้ไปที่การดูแลจากศูนย์กลาง >> การตรวจสอบ >> งานตัวจับเวลา >> ตรวจสอบคำจำกัดความของงาน >> เลือกเป้าหมายของคุณจากรายการงานตัวจับเวลาใน SharePoint 2013 >> คลิกที่ปุ่ม "ปิดใช้งาน" เพื่อปิดใช้งานตัวจับเวลา งาน.
ปิดการใช้งานตัวจับเวลาของ SharePoint โดยใช้ PowerShell
นี่คือ PowerShell เพื่อปิดการใช้งานตัวจับเวลาใน SharePoint:
#Function to Disable a Timer job
Function Disable-TimerJob($TimerJobName)
{
$TimerJob = Get-SPTimerJob | Where-Object { $_.displayname -like $TimerJobName }
if($TimerJob -eq $null)
{
Write-host "Timer job not found!" -ForegroundColor Red
return
}
$TimerJobDisabled = $TimerJob | Select -ExpandProperty IsDisabled
if($TimerJobDisabled)
{
Write-host "Timer Job is already Disabled!" -ForegroundColor Yellow
}
else
{
$TimerJob | Disable-SPTimerJob
Write-host "Timer Job Disabled!" -ForegroundColor Green
}
}
#Timer job name to disable
$TimerJobName="My Site Cleanup Job"
#Call the function to Disable Timer job
Disable-TimerJob $TimerJobName
เปิดใช้งานงานตัวจับเวลาใน SharePoint:
หากต้องการเปิดใช้งานงานตัวจับเวลาที่ปิดใช้งาน ให้ไปที่:
- การบริหารส่วนกลาง >> การตรวจสอบ >> งานจับเวลา
- ตรวจสอบคำจำกัดความของงาน >> เลือกเป้าหมายของคุณจากรายการงานตัวจับเวลาใน SharePoint 2013
- คลิกที่ปุ่ม "เปิดใช้งาน" เพื่อเปิดใช้งานงานตัวจับเวลา
ซึ่งเปิดใช้งานงานตัวจับเวลาที่ปิดใช้งานใน SharePoint 2013
เปิดใช้งานงาน SharePoint Timer ด้วย PowerShell:
#Function to Enable a Timer job
Function Enable-TimerJob($TimerJobName)
{
$TimerJob = Get-SPTimerJob | Where-Object { $_.displayname -like $TimerJobName }
if($TimerJob -eq $null)
{
Write-host "Timer job not found!" -ForegroundColor Red
return
}
$TimerJobDisabled = $TimerJob | Select -ExpandProperty IsDisabled
if($TimerJobDisabled)
{
$TimerJob | Enable-SPTimerJob
Write-host "Timer Job Enabled!" -ForegroundColor Green
}
else
{
Write-host "Timer Job is Already Enabled!" -ForegroundColor Yellow
}
}
#Timer job name to Enable
$TimerJobName="My Site Cleanup Job"
#Call the function to Enable Timer job
Enable-TimerJob $TimerJobName
นี่เป็นการเปิดใช้งานงานตัวจับเวลาใน SharePoint 2010 ด้วย PowerShell

