通过PowerShell更改SSRS报告订阅的描述

时间:2016-07-18 11:27:28

标签: powershell ssrs-2008 powershell-v2.0 powershell-v3.0 ssrs-2012

我有一个PowerShell脚本,我想更新符合某些条件的一些SSRS报告订阅的说明。我知道以下方法。

$proxy.ChangeSubscriptionOwner()

同样,我们是否有任何更新描述的机制?请建议。

1 个答案:

答案 0 :(得分:0)

我知道这还没有得到你的答案,但也许它会让你部分到那里。

以下是如何通过订阅获取所有报告的方法。

function Get-DataDrivenSubscriptionProperties 
{
  param([string] $Subscriptionid,
   [object]$ssrsproxy) 
   $ddextensionSettings = $ddDataRetrievalPlan = $ddDescription = $ddactive = $ddstatus = $ddeventtype = $ddmatchdata = $ddparameters = $Null
    $ddOwner = $ssrsproxy.GetDataDrivenSubscriptionProperties($subscriptionid,[ref]$ddextensionSettings,[ref]$ddDataRetrievalPlan,[ref]$ddDescription,[ref]$ddactive,[ref]$ddstatus,[ref]$ddeventtype,[ref]$ddmatchdata,[ref]$ddparameters)
    [PSCustomObject]@{
        'Owner' = $ddOwner
        'extensionSettings' = $ddextensionSettings
        'DataRetrievalPlan' = $ddDataRetrievalPlan
        'Description' = $ddDescription
        'active' = $ddactive
        'status' =$ddstatus
        'eventtype' =$ddeventtype 
        'matchdata' = $ddmatchdata
        'parameters' = $ddparameters
      }
}
function Get-SubscriptionProperties
{
  param([string]$Subscriptionid,
  [object]$ssrsproxy)
  $subextensionSettings = $subDataRetrievalPlan = $subDescription = $subactive = $substatus = $subeventtype = $submatchdata = $subparameters = $Null

  $subOwner = $ssrsproxy.GetSubscriptionProperties($subscriptionid,[ref]$subextensionSettings,[ref]$subDescription,[ref]$subactive,[ref]$substatus,[ref]$subeventtype,[ref]$submatchdata,[ref]$subparameters)
      [PSCustomObject]@{
        'Owner' = $subOwner
        'extensionSettings' = $subextensionSettings
        'Description' = $subDescription
        'active' = $subactive
        'status' =$substatus
        'eventtype' =$subeventtype 
        'matchdata' = $submatchdata
        'parameters' = $subparameters
      }

}
function Get-Subscriptions
{
  #Returns a nested object with each 
  param([object]$ssrsproxy, [string]$site)
  #write-verbose 'Path to where the reports are must be specified to get the subscriptions you want.. Root (/) does not seem to get everything'
  $items = $ssrsproxy.ListChildren($site,$true) | Where-Object{$_.typename -eq 'report'}
  $subscriptions = @()
  foreach($item in $items)
  {
    $subs = $ssrsproxy.ListSubscriptions($item.path)
    $count = $subs.count
    write-verbose "found $($subs.count) subscriptions for $($item.Name)"
    $subprops = @()
    if($subs)
    {
      $s = @()
      foreach($sub in $subs)
      {

        if($sub.isdatadriven -eq 'true')
        {
          $subprops += Get-DataDrivenSubscriptionProperties -subscriptionid $sub.SubscriptionID -ssrsproxy $ssrsproxy
          $sub | add-member -MemberType NoteProperty -Name Properties -value $subprops -TypeName [PSCustomObject]
        }
        else
        {
          $subprops +=   Get-SubscriptionProperties -subscriptionid $sub.SubscriptionID -ssrsproxy $ssrsproxy
          $sub | add-member -MemberType NoteProperty -Name Properties -value $subprops -TypeName [PSCustomObject]
        }

      }

      $item | add-member -MemberType NoteProperty -Name Subscriptions -Value $subs -TypeName [PSCustomObject]
      $item | Add-Member -MemberType NoteProperty -Name 'SubscriptionCount' -Value $count 
    }
    else 
    {
      $count = 0
    } 
  if($count -ne 0)
    {
      $subscriptions += $item
    }
  }
  $subscriptions
}
function New-SubscriptionFile
{
    [CmdletBinding()]
    [Alias()]
    param([psobject]$subscriptionObject, [string]$path)
    if(test-path $path -PathType Leaf)
    {$path = split-path $path}
    foreach($sub in $subscriptionObject)
    {
      $reportName = (($sub.name).split('.'))[0]
      $filename = "$path\$reportName.xml"
      $sub | Export-Clixml -Path $filename -Depth 100 
    }
}
相关问题