I am trying to get the connection string of a database datasource with the following script:
$Analysis_Server = New-Object Microsoft.AnalysisServices.Server
found this in a post here: http://www.mrtsql.com/2011/03/powershell-updating-analysis-services.html
See if this function in that post helps you out.
function UpdateDataSources()
{
# Lets get our server name
$SSASServerName="$env:ComputerName\" + $SSASInstanceName
$MyConnection = New-Object("Microsoft.AnalysisServices.Server")
$MyConnection.Connect($SSASServerName)
# lets return the number of data sources
[int]$DataSourcecount=$MyConnection.Databases[$DatabaseName].DataSources.count
for ($count=0; $count -ne $DataSourcecount;++$count)
{
$MyCS=$MyConnection.Databases[$DatabaseName].DataSources[$count].ConnectionString
$NewCS=setNewValue -MyCS $MyCS -Pattern "Data Source=" -ReplaceWith $DataSourceServer
if ($PW.Length -ne 0)
{
$NewCS=setNewValue -MyCS $NewCS -Pattern "Password=" -ReplaceWith $PW
}
if ($UserName.length -ne 0)
{
$NewCS=setNewValue -MyCS $NewCS -Pattern "User ID=" -ReplaceWith $UserName
}
$MyConnection.Databases[$DatabaseName].DataSources[$count].ConnectionString=$NewCS
# write the change back to SSAS
$MyConnection.Databases[$DatabaseName].DataSources[$count].update()
write-output $NewCS
}
}