Change description of an SSRS report subscription through PowerShell

powershell ssrs-2008 powershell-2.0 powershell-3.0 ssrs-2012

306 просмотра

1 ответ

672 Репутация автора

I have a PowerShell script and I would like to update descriptions of couple of my SSRS report subscriptions that meets some criteria. I am aware of below method.

$proxy.ChangeSubscriptionOwner()

Likewise do we have any mechanisms to update descriptions as well? Please suggest.

Автор: Bijoy K Jose Источник Размещён: 18.07.2016 11:27

Ответы (1)


0 плюса

923 Репутация автора

I know this doesn't yet get to your answer but maybe it'll get you partially there.

Here is how you can get all the reports with subscriptions.

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 
    }
}
Автор: thom schumacher Размещён: 31.03.2017 04:58
Вопросы из категории :
32x32