Kishore

Kishore

  • NA
  • 65
  • 8.6k

PowerShell deploy SSRS with datasource

Jan 18 2017 4:30 AM
Hi all I am trying to deploy SSRS using PowerShell as follows which is creating the report but not the datasource. 

I tried the approach from here but not working as expected

https://blogs.infosupport.com/managing-ssrs-reports-with-powershell/#comment-124935

http://hindenes.com/powershell/SQLReporting.psm1

 $ssrsproxy = New-WebServiceProxy -Uri $webServiceUrl -UseDefaultCredential -Namespace "SSRS"  
  1. $proxyNameSpace = $ssrsproxy.gettype().Namespace  
  2. $datasourceDef = New-Object("$proxyNameSpace.DataSourceDefinition")  
  3.   
  4.     $datasourceDef.connectstring = $connectString  
  5.     $datasourcedef.Extension = $Extension  
  6.     $datasourceDef.Enabled = $true  
  7.     $datasourceDef.EnabledSpecified = $true  
  8.     $datasourceDef.ImpersonateUserSpecified = $false  
  9.     $datasourceDef.Prompt = $null  
  10.     $datasourceDef.WindowsCredentials = $false  
  11.   
  12.     try  
  13.     {  
  14.         $ssrsproxy.CreateDataSource($DataSourceName, $path, $true, $datasourceDef, $null)  
  15.     }  
  16.     catch  
  17.     {  
  18.         "Error was $_"  
  19.         $line = $_.InvocationInfo.ScriptLineNumber  
  20.         "Error was in Line $line"  
  21.     }  
 
 
Error was Cannot convert argument "Definition", with value: "SSRS.DataSourceDefinition", for "CreateDataSource" to type "SSRS.DataSourceDefinition ": "Cannot convert the "SSRS.DataSourceDefinition" value of type "SSRS.DataSourceDefinition" to type "SSRS.DataSourceDefinition"." Error was in Line 47