使用powershell更改SSRS中的凭据检索

使用powershell更改SSRS中的凭据检索,powershell,reporting-services,Powershell,Reporting Services,我想将SSRS数据源凭据检索从使用以下凭据更改为使用powershell时不使用任何凭据,脚本失败 我想根据本文将值“Store”更改为“None”: 这是我的代码: $uri ='http://ServerName/ReportServer/ReportService2010.asmx?wsdl' $reporting = New-WebServiceProxy -uri $uri -UseDefaultCredential -namespace "ReportingWebService"

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

我想根据本文将值“Store”更改为“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.InvalidelElementCombinationException:用户名和凭据检索字段的值组合无效。“ 第13行字符数:4 +$reporting.SetDataSourceContents($Object.path,$dataSource) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:NotSpecified:(:)[],MethodInvocationException +FullyQualifiedErrorId:SoapException


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

$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)
  }

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

$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)
  }