Skip to content

Instantly share code, notes, and snippets.

@daveselias
Last active August 29, 2015 14:05
Show Gist options
  • Save daveselias/7ae32f24d117a5d8c350 to your computer and use it in GitHub Desktop.
Save daveselias/7ae32f24d117a5d8c350 to your computer and use it in GitHub Desktop.
PS script for updating the Connection string value in SSRS shared data sources
$OldSource = 'MySQLServer-01'
$NewSource = 'MySQLServer-02'
$URL = 'http://ReportServerName/ReportServer/ReportService2010.asmx?wsdl'
$URI = New-Object System.Uri($URL)
$SSRS = New-WebServiceProxy -Uri $URI -UseDefaultCredential
$DataSources = ($SSRS.ListChildren("/data sources", $true)).path
ForEach($Source in $DataSources){
$DS = $SSRS.GetDataSourceContents($Source)
IF($DS.ConnectString -like "*$OldSource*"){
$String = $DS
$String.ConnectString = $String.ConnectString.Replace($OldSource,$NewSource)
$SSRS.SetDataSourceContents($Source,$string)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment