Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web services SSRS如何使用Powershell获取报告缓存选项?_Web Services_Powershell_Reporting Services_Ssrs 2016 - Fatal编程技术网

Web services SSRS如何使用Powershell获取报告缓存选项?

Web services SSRS如何使用Powershell获取报告缓存选项?,web-services,powershell,reporting-services,ssrs-2016,Web Services,Powershell,Reporting Services,Ssrs 2016,在SSRS web界面中,单击报告并转到“管理-->缓存”(如果报告配置为“始终针对预生成的快照运行此报告”),则会出现一个缓存快照部分,其中有一个选项“按计划创建缓存快照” 我一直在玩弄PowerShell,试图创建一个脚本,找到设置了此选项的所有报告,并输出时间表 我有一个脚本,它以“Snapshot”的“Execution Type”迭代每个报告,但我认为我调用了错误的方法(GetCacheOptions),因为它为每个项目返回的所有结果都是False: Clear-Host  $we

在SSRS web界面中,单击报告并转到“管理-->缓存”(如果报告配置为“始终针对预生成的快照运行此报告”),则会出现一个缓存快照部分,其中有一个选项“按计划创建缓存快照”

我一直在玩弄PowerShell,试图创建一个脚本,找到设置了此选项的所有报告,并输出时间表

我有一个脚本,它以“Snapshot”的“Execution Type”迭代每个报告,但我认为我调用了错误的方法(GetCacheOptions),因为它为每个项目返回的所有结果都是False:

Clear-Host 

$webServiceUrl = 'http://myReportServer.domain.com/reportserver/reportservice2010.asmx?WSDL'

$rs = New-WebServiceProxy -Class 'RS' -Namespace 'RS' -Uri $webServiceUrl -UseDefaultCredential

$reports = $rs.ListChildren("/Some Folder", $true) | Where-Object { $_.TypeName -eq "Report" }

$schedDef = New-Object RS.ScheduleDefinition
$expDef = New-Object RS.ExpirationDefinition

foreach ($report in $reports) {

    $execType = $rs.GetExecutionOptions($report.Path, [ref]$schedDef.Item)


    if($execType -eq "Snapshot") {
        $rs.GetCacheOptions($report.Path, [ref]$expDef.Item)
    }

}
是否有人知道需要调用什么方法来获取此信息以及如何调用此方法(即需要提供哪些参数)

编辑:

根据已接受答案的指导,我能够进行一些编辑(如下),但我没有得到我想要的日程信息:

.......
....
foreach ($report in $reports) {

    $execResult = $rs.GetExecutionOptions($report.Path,
        [ref]$ScheduleDefinitionOrReference)

    if ($execResult -eq "Snapshot") {
        if($ScheduleDefinitionOrReference.Item -is [RS.DailyRecurrence]) {
            Write-Host "$($report.Name):" -f Green
            Write-Host "`tSchedule Information:" -f Yellow
            Write-Host "`t`tEvery $($ScheduleDefinitionOrReference.Item.Daysinterval) Day(s)"
            Write-Host "`t`tStart Time: $($ScheduleDefinitionOrReference.StartDateTime)`n"
        }

    }
您可以使用并将
ItemPath
out bool KeepExecutionSnapshots
以及
out scheduleDefinition或引用传递给该方法

如果选中“在计划上创建缓存快照”,则
ScheduleDefinition或reference
将包含
ScheduleDefinition
,否则其值将为
NoSchedule

示例

$svcUrl = 'http://the-host-name/ReportServer/reportservice2010.asmx'
$svc = New-WebServiceProxy -Class 'RS' -Namespace 'RS' -Uri $svcUrl -UseDefaultCredential
$reports = $svc.ListChildren("/", $true) | Where-Object { $_.TypeName -eq "Report" }

$KeepExecutionSnapshots = $false
$ScheduleDefinitionOrReference = New-Object RS.ScheduleDefinitionOrReference

foreach ($report in $reports) {
    $svc.GetItemHistoryOptions($report.Path, 
        [ref]$KeepExecutionSnapshots, 
        [ref]$ScheduleDefinitionOrReference)
    $report.Path
    $ScheduleDefinitionOrReference
}

这不完全是我想要的,但你让我走上了正确的方向!谢谢我能够使用GetExecutionOptions()方法,但我误解了如何正确使用[ref]变量。包括对我的答案的一些更新,仅供任何人查看我是如何获得我需要的工作的。再次感谢!仅供参考,在18小时内不会让我奖励赏金。一旦我有能力,我一定会这么做!不客气。我测试了
GetItemHistoryOptions
,如我所述,如果选中计划上的创建缓存快照,ScheduleDefinitionOrReference参数将包含计划对象,否则其值将为NoSchedule。所以我想你也可以用它。我没有检查GetExecutionOptions,但根据文档,它为您提供了解决方案。如果项目的执行选项不包含计划信息,则输出参数为计划,否则项目参数为NoScheduleobject。