I need to change the datasource of multiple ssrs data-Driven subscriptions using PowerShell. I have this code which can get the properties of data-Driven subscription but I need to fetch the datasource details first and then change it to also.
Here is my code.
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
}
}
$ServiceUserPWD="************"
$ServiceUserName="Domain\UserName"
$DataSource = "/MyReports/EUROPE/M5EMPRDG"
$ReportFullPath = "/MyReports/EUROPE/rpt_Person";
$secpasswd = ConvertTo-SecureString "$ServiceUserPWD" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($ServiceUserName, $secpasswd)
$ssrsServer = "https:/myserver/Reportserver";
$ssrsProxy = New-WebServiceProxy -Uri "$($ssrsServer)/ReportService2010.asmx?WSDL" -Credential $mycreds;
# Get the report subscriptions
$subscriptions = $ssrsProxy.ListSubscriptions($ReportFullPath)
foreach ($sub in $subscriptions)
{
if($sub.isdatadriven -eq 'true')
{
$subprops += Get-DataDrivenSubscriptionProperties -subscriptionid $sub.SubscriptionID -ssrsproxy $ssrsProxy
$sub | add-member -MemberType NoteProperty -Name Properties -value $subprops -TypeName [PSCustomObject]
}
}
Till here I can write this code, but in this $sub there is no details of datasource so I am not able to change the datasource.
Please help to give me complete code to get the datasource and change the datasource of data-driven subscription.
thank you.