You can find lot of articles online,for my reference posting this article.
Running powershell script for scheduled task is not that complex,you can create a powershell script and run schedule basis.the below script is for clearing the cache on a schedule basis, best practice is not to clear the cache often,it will effect to your site performance.
Basic script:
ForEach($site in
[Sitecore.Configuration.Factory]::GetSiteNames()) {
$siteInfo =
[Sitecore.Configuration.Factory]::GetSiteInfo($site)
if($siteInfo -ne
$null) {
$siteInfo.HtmlCache.Clear()
$logEntry =
[string]::Format("mahe through Scheduled Task your HtmlCache.Clear()
invoked for {0}", $siteInfo.Name)
Write-Log
$logEntry
Write-Host
$logEntry
}
}
1)
Write above script in your powershell ISE and
excute if it’s working fine save as [some name] PowerShellHtmlCacheClearTask
2)
/sitecore/system/Modules/PowerShell/Script
Library/Task Management/Content Editor/Insert Item/PowerShellHtmlCacheClearTask
![]() |
Creating the Scheduled Task
- Goto /sitecore/system/Tasks/Schedules
- Click on the Schedules and insert PowerShell Scripted Task Schedule
1 Give the name SchedulePowerShellScript
2 Select the Powershell task you created in 1st
step
Click on the create
Select the timings when you want to run and how often it
should run
You will see on the SPElogs your task running
Referred articles.
https://sitecorejunkie.com/2014/05/31/execute-powershell-scripts-in-scheduled-tasks-using-sitecore-powershell-extensions/
https://doc.sitecorepowershell.com/modules/integration-points/tasks
https://sitecorejunkie.com/2014/05/31/execute-powershell-scripts-in-scheduled-tasks-using-sitecore-powershell-extensions/
https://doc.sitecorepowershell.com/modules/integration-points/tasks
No comments:
Post a Comment