HowTo call ReportService2010.SetCacheOptions( ) and reference a shared schedule with powershell or C#?
Hi, i want to programmatically set the "ExecutionOptions" as shown bellow: -Cache Report, Retire based on a shared Schedule I managed already to lookup the object of the sharedschedule and want now to pass this in to SetCacheOptions Method of SSRS webservice. Unfortunately i alway get following error when trying to execute the method: How can i cast/convert "RS.Schedule" to "RS.ExpirationDefinition"? All i want is to reference the existing sharedSchedule in the SetCacheOptions call..but how to do? Here's the partially working powershell script (You need Powershell V3 installed!): $reportServerURI = "http://localhost/Reportserver" $ReportPathWildCard = "/"; $NameSharedSchedule="NeverExpireCache"; # init WS proxy $reportServerURI2010 = "$reportServerURI/ReportService2010.asmx?WSDL" $RS = New-WebServiceProxy -Class 'RS' -NameSpace 'RS' -Uri $reportServerURI2010 -UseDefaultCredential #Get Schedule Reference $NeverExpireSchedule= $rs.ListSchedules([System.Management.Automation.Language.NullString]::Value) | where {$_.Name -eq "$NameSharedSchedule"} $NeverExpireScheduleID = $NeverExpireSchedule.ScheduleID; Write-Host "Found Shared Schedule $NameSharedSchedule with id $NeverExpireScheduleID"; #get list of reports $reports = $RS.ListChildren($ReportPathWildCard,$true) | WHERE {$_.TypeName -eq "Report"} #process all items foreach ($report in $reports) { $xpath = $report.path $xtype = $report.TypeName Write-Host "Processing $xtype $xpath" ##get actual setting $s = New-Object("RS.ScheduleDefinitionOrReference") $r = $RS.GetExecutionOptions($xpath,[ref] $s); Write-Host "--Actual Setting: $r" $s = New-Object("RS.ExpirationDefinition") $r = $RS.GetCacheOptions($xpath,[ref] $s); If ($r) { Write-Host "--Actual Setting: Cache a temporary copy of the report. Expire copy of report on the following schedule " $s.Item.ScheduleID; } ##SET Cache #$o = New-Object("RS.ExpirationDefinition"); $o = New-Object("RS.ExpirationDefinition"); $o = $NeverExpireSchedule.Definition $r= $RS.SetCacheOptions( $xpath,[System.Management.Automation.Language.NullString]::Value, $NeverExpireSchedule) }
August 15th, 2012 9:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics