set cache refresh schedule for report ssrs
I have s h*tload of reports on my reportserver. Most of them have a Cache
Refresh Plan using a shared schedule. Is it programmatically possible to
set a Cache Refresh Plan on a report? Enabling caching, set expiration for
a cache using a shared schedule, running snapshots according to a shared
schedule all works runs fine using SetExecutionOptions-method and
SetCacheOptions-method.
Setting a Cached Refreshplan for a report however does NOT run fine.
Suggestions?
edit: I would like to do the same for all, datasets set them to refresh on
a shared schedule.
Below is the code I am using (Powershell V3)
$reportServerURI = "http://localhost/Reportserver"
$ReportPathWildCard = "/SOME/FOLDER/ON/SERVER";
$NameSharedSchedule="NAMEOFSCHEDULE";
# init WS proxy
$reportServerURI2010 = "$reportServerURI/ReportService2010.asmx?WSDL"
$RS = New-WebServiceProxy -Uri $reportServerURI2010 -UseDefaultCredential
$proxyNamespace = $RS.GetType().Namespace
#Get Schedule Reference
$NeverExpireSchedule=
$RS.ListSchedules([System.Management.Automation.Language.NullString]::Value)
| where {$_.Name -eq "$NameSharedSchedule"}
$NeverExpireScheduleID = $NeverExpireSchedule.scheduleid;
$NeverExpireDescription = $NeverExpireSchedule.Description;
$NeverExpireDefinition = $NeverExpireSchedule.Definition;
Write-Host "Found Shared Schedule: '$NameSharedSchedule' with id
$NeverExpireScheduleID and definition $NeverExpireDescription";
$NeverExpireScheduleRef =New-Object("$proxyNamespace.ScheduleReference");
$NeverExpireScheduleRef.ScheduleID=$NeverExpireScheduleID;
#get all needed items
$items = $RS.ListChildren($ReportPathWildCard, $true) | Where-Object
{"Report" -contains $_.TypeName}
#process all items
foreach ($item in $items) {
$xpath = $item.path
$xtype = $item.TypeName
Write-Host "Processing $xtype $xpath"
##SET Refresh
$r= $RS.SetExecutionOptions( $xpath,"Snapshot",$NeverExpireDefinition)
}
No comments:
Post a Comment