【问题标题】:Change Credential Retrieval in SSRS with powershell使用 powershell 在 SSRS 中更改凭据检索
【发布时间】:2019-11-22 12:49:48
【问题描述】:

我想将 SSRS 数据源凭据检索从使用以下凭据更改为不使用任何凭据,并且使用 powershell 并且脚本失败。

我想根据这篇文章将值“存储”更改为“无”: https://docs.microsoft.com/en-us/dotnet/api/reportservice2010.credentialretrievalenum?view=sqlserver-2016#ReportService2010_CredentialRetrievalEnum_None

这是我的代码:

$uri ='http://ServerName/ReportServer/ReportService2010.asmx?wsdl'

$reporting = New-WebServiceProxy -uri $uri -UseDefaultCredential -namespace "ReportingWebService"
$DataSources = $reporting.ListChildren('/', $true) | Where-Object  {$_.Name -eq "DataSourceName"}   

  foreach($Object in $DataSources) {
   $dataSource =$reporting.GetDataSourceContents($Object.path)
   #$dataSource.CredentialRetrieval="None"
  $dataSource.CredentialRetrieval=[ReportingWebService.CredentialRetrievalEnum]::None
   $reporting.SetDataSourceContents($Object.path,$dataSource)
 }

这是错误:

使用“2”参数调用“SetDataSourceContents”的异常:“字段 UserName 和 CredentialRetrieval 的值组合无效。---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidElementCombinationException:UserName 和 CredentialRetrieval 字段的值组合无效。” 在行:13 字符:4 + $reporting.SetDataSourceContents($Object.path,$dataSource) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapException

【问题讨论】:

    标签: powershell reporting-services


    【解决方案1】:

    问题是我实际上没有使用必需的用户名参数更改现有的凭据检索设置“存储”。 要解决它,我应该使用新的凭据检索设置创建新的数据源定义并将其应用于我的数据源:

    $uri ='http://servername/ReportServer/ReportService2010.asmx?wsdl'
    $reporting = New-WebServiceProxy -uri $uri -UseDefaultCredential
    $type=$reporting.GetType().Namespace
    $DataSources = $reporting.ListChildren('/', $true) | Where-Object  {$_.Name -eq "Data source name"} 
    
     foreach($Object in $DataSources) {
       $dataSource =$reporting.GetDataSourceContents($Object.path)
        $dataSourceDefinitionType = ($type + '.DataSourceDefinition');
        $dataSourceDefinition = New-Object ($dataSourceDefinitionType);
        $dataSourceDefinition.Extension = $dataSource.Extension; #get data from existent data source definition
        $dataSourceDefinition.ConnectString = $dataSource.ConnectString #get data from existent data source definition
        $credentialRetrievalDataType = ($type + '.CredentialRetrievalEnum'); 
        $credentialRetrieval = new-object ($credentialRetrievalDataType);
        $credentialRetrieval.value__ = 3;
        $dataSourceDefinition.CredentialRetrieval = $credentialRetrieval;
        $dataSourceDefinition.WindowsCredentials = $dataSource.WindowsCredentials; #get data from existent data source definition
        $dataSourceDefinition.Enabled = $dataSource.Enabled; #get data from existent data source definition
        $dataSourceDefinition.EnabledSpecified = $dataSource.EnabledSpecified; #get data from existent data source definition
        $reporting.SetDataSourceContents($Object.path,$dataSourceDefinition)
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      • 2013-07-18
      • 1970-01-01
      • 1970-01-01
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多