1

私は移行後のSSRSレポート管理作業のために働いているPowershellスクリプトを持っています。SSRS Powershellスクリプトでこれらのエラーが表示されるのはなぜですか?

この特定のシナリオでは、SSRSの単一のインスタンスをホストするDEV環境(主にテストしています)と、4つのノードにわたる拡張された環境であるProd環境があります。

私はPowerShellの(わずか2日前にそれを発見しました...)に新たなんだと私は持っているスクリプトは非常に単純です:

Clear-Host  

$Username = "domain\myUsername" 
$Password = "myPassword" 

$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($Username,(ConvertTo-SecureString -String $Password -AsPlainText -Force)) 

# Dev Connection String 
$webServiceUrl = 'http://DEVwebServer.domain.com/reportserver/reportservice2010.asmx?WSDL' 

# Prod Connection String 
# $webServiceUrl = 'http://PRODwebServerNode1.domain.com/reportserver/reportservice2010.asmx?WSDL' 

$rs = New-WebServiceProxy -Uri $webServiceUrl -Credential $Cred 
  
$reports = $rs.ListChildren("/Some Folder Under Root", $true) | Where-Object { $_.TypeName -eq "Report" } 

$type = $ssrsProxy.GetType().Namespace; 
$schedDefType = "{0}.ScheduleDefinition" -f $type; 
$schedDef = New-Object ($schedDefType) 

$warning = @(); 

foreach ($report in $reports) { 

    $sched = $rs.GetExecutionOptions($report.Path, [ref]$schedDef); 
    $snapShotExists = $rs.ListItemHistory($report.Path); 


    if($sched -eq "Snapshot") { 
     Write-Host "Following report is configured to run from Snapshot:" -ForegroundColor Yellow 
     Write-Host ("Report Name: {0}`nReport Path: {1}`nExecution Type: {2}`n" -f $report.Name, $report.Path, $sched) 

     if ($snapShotExists) { 
      Write-Host "Does Snapshot Exist..?`n" -ForegroundColor Yellow 
      Write-Host "Yes!`tNumber of Snapshots: " $snapShotExists.Count -ForegroundColor Green 
      $snapShotExists.CreationDate 
      Write-Host "`n------------------------------------------------------------" 
     } 
     elseif (!$snapShotExists) { 
      Write-Host "Does Snapshot Exist..?`n" -ForegroundColor Yellow 
      Write-Host ("No!`n") -ForegroundColor Red 
      Write-Host "Creating Snapshot.......`n" -ForegroundColor Yellow 
      $rs.CreateItemHistorySnapshot($report.Path, [ref]$warning); 
      Write-Host "Snapshot Created!`n" -ForegroundColor Green 
      $snapShotExists.CreationDate 
      Write-Host "`n------------------------------------------------------------" 
     } 
    } 
} 

スクリプトの目的は、再帰的にすべてを反復処理するだけです$ reports変数の指定されたフォルダのレポート、実行タイプが「スナップショット」に設定されているかどうかを確認し、「履歴スナップショット」が存在するかどうかをチェックし、存在しない場合は作成します。

私はdevにこれを実行すると、それだけで正常に動作しますが、私はPRODで実行したときに、私は次のエラーが私のforeachループ内の各$レポートのために繰り返さ取得:

enter image description here

なぜこの上の任意のアイデア1つではなく他の人で動作し、このエラーをどのように克服するのでしょうか?

+0

...私はよく分からないが、それはそうせずにDevの中で働いていた理由キーの変更は、スケジュール定義オブジェクトから「アイテム」プロパティに必ず作っていたと思います2台のマシンのPSバージョンが異なる場合(PSプロンプトから '$ PSVersionTable.PSVersion'を使用して)同じバージョンの2台のマシンをすべて取得する必要があるかもしれません。 –

答えて

0

私はガイドとしてthis answerを使用して、いくつかの調整を行うことにより、製品版インスタンス上でこの作業を取得することができた:私は更新することができた、

クラスと名前空間フラグを追加するには、New-たWebServiceProxyに私の呼び出しを更新することにより、次の方法でスクリプト:私はそれはあなたを確保するためだけのきれいな方法だと思うよう

... 
# Add Class and Namespace flags to New-WebServiceProxy call 
$rs = New-WebServiceProxy -Class 'RS' -Namespace 'RS' -Uri $webServiceUrl -Credential $Cred 
  
$reports = $rs.ListChildren("/Business and Technology Solutions", $true) | Where-Object { $_.TypeName -eq "Report" } 

# Declare new "ScheduleDefintion object using the Class declared in the New-WebServiceProxy call 
$schedDef = New-Object RS.ScheduleDefinition 
$warning = @(); 

foreach ($report in $reports) { 

    # Referencing the "Item" property from the ScheduleDefinition 
    $execType = $rs.GetExecutionOptions($report.Path, [ref]$schedDef.Item) 

... 

私は新しい-たWebServiceProxyコールにクラスと名前空間のフラグを追加することはないと思うが、それをやったまさにでしたWebServiceから適切な名前空間を取得しています。たぶんちょっとした砂糖。

私が見てチェックすることにより、スタート

関連する問題