ConnectionString property not printing connection string









up vote
1
down vote

favorite












I am trying to get the connection string of a database datasource with the following script:



 $Analysis_Server = New-Object Microsoft.AnalysisServices.Server 
$Analysis_Server.connect("$server")

$database = $Analysis_Server.Databases[7]
$c = $database.DataSources[0].ConnectionString
$c


nothing is outputting.



I have tried debugging like so:



$Analysis_Server.Databases


this prints out all databases on the server



if i index it $Analysis_Server.Databases, it prints whatever database is indexed (so in my case, 7, prints database8)



clearly the Database property is working.



-------------UPDATE:--------------



here is how the Databases look in the server



server1_Databses



here is what each of the following lines does:



 $Analysis_Server.Databases


this prints out



Databses



One thing one can notice is for some reason they are printed out not in order of how they are on the analysis server as in the picture...I dont know why that is the case



this is what this command prints out:



Analysis_Server.Databases[0]


Database8



Now since index 0 worked, we should be able to index [1], [2], etc...



so the following



Analysis_Server.Databases[1] 
Analysis_Server.Databases[2]


prints:



databases1 and 3



Now unto the connection string:



$Analysis_Server.Databases[0].DataSources[0].ConnectionString


that prints out:




Connection Timeout=60;User Id=someID;Data Source=10.10.10.10;Persist Security Info=True




its appears to be the connection string for Database8



cool, so then we should be able to do this as well:



$Analysis_Server.Databases[1].DataSources[0].ConnectionString


However, nothing prints! the only index that seems to print is with Databases[0]



This is what $Analysis_Server.Databases[0].DataSources[0] prints:



DataSources0



we should be able to do the same for all databases



$Analysis_Server.Databases[1].DataSources[0]



$Analysis_Server.Databases[2].DataSources[0]
etc..



but nothing gets printed!










share|improve this question























  • you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
    – Paul
    Oct 29 at 9:47










  • @Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
    – Cataster
    Oct 29 at 12:25











  • Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
    – thom schumacher
    Oct 30 at 14:20










  • @thomschumacher please check my UPDATE section
    – Cataster
    Oct 30 at 17:26






  • 1




    @thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
    – Cataster
    Oct 31 at 16:34














up vote
1
down vote

favorite












I am trying to get the connection string of a database datasource with the following script:



 $Analysis_Server = New-Object Microsoft.AnalysisServices.Server 
$Analysis_Server.connect("$server")

$database = $Analysis_Server.Databases[7]
$c = $database.DataSources[0].ConnectionString
$c


nothing is outputting.



I have tried debugging like so:



$Analysis_Server.Databases


this prints out all databases on the server



if i index it $Analysis_Server.Databases, it prints whatever database is indexed (so in my case, 7, prints database8)



clearly the Database property is working.



-------------UPDATE:--------------



here is how the Databases look in the server



server1_Databses



here is what each of the following lines does:



 $Analysis_Server.Databases


this prints out



Databses



One thing one can notice is for some reason they are printed out not in order of how they are on the analysis server as in the picture...I dont know why that is the case



this is what this command prints out:



Analysis_Server.Databases[0]


Database8



Now since index 0 worked, we should be able to index [1], [2], etc...



so the following



Analysis_Server.Databases[1] 
Analysis_Server.Databases[2]


prints:



databases1 and 3



Now unto the connection string:



$Analysis_Server.Databases[0].DataSources[0].ConnectionString


that prints out:




Connection Timeout=60;User Id=someID;Data Source=10.10.10.10;Persist Security Info=True




its appears to be the connection string for Database8



cool, so then we should be able to do this as well:



$Analysis_Server.Databases[1].DataSources[0].ConnectionString


However, nothing prints! the only index that seems to print is with Databases[0]



This is what $Analysis_Server.Databases[0].DataSources[0] prints:



DataSources0



we should be able to do the same for all databases



$Analysis_Server.Databases[1].DataSources[0]



$Analysis_Server.Databases[2].DataSources[0]
etc..



but nothing gets printed!










share|improve this question























  • you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
    – Paul
    Oct 29 at 9:47










  • @Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
    – Cataster
    Oct 29 at 12:25











  • Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
    – thom schumacher
    Oct 30 at 14:20










  • @thomschumacher please check my UPDATE section
    – Cataster
    Oct 30 at 17:26






  • 1




    @thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
    – Cataster
    Oct 31 at 16:34












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to get the connection string of a database datasource with the following script:



 $Analysis_Server = New-Object Microsoft.AnalysisServices.Server 
$Analysis_Server.connect("$server")

$database = $Analysis_Server.Databases[7]
$c = $database.DataSources[0].ConnectionString
$c


nothing is outputting.



I have tried debugging like so:



$Analysis_Server.Databases


this prints out all databases on the server



if i index it $Analysis_Server.Databases, it prints whatever database is indexed (so in my case, 7, prints database8)



clearly the Database property is working.



-------------UPDATE:--------------



here is how the Databases look in the server



server1_Databses



here is what each of the following lines does:



 $Analysis_Server.Databases


this prints out



Databses



One thing one can notice is for some reason they are printed out not in order of how they are on the analysis server as in the picture...I dont know why that is the case



this is what this command prints out:



Analysis_Server.Databases[0]


Database8



Now since index 0 worked, we should be able to index [1], [2], etc...



so the following



Analysis_Server.Databases[1] 
Analysis_Server.Databases[2]


prints:



databases1 and 3



Now unto the connection string:



$Analysis_Server.Databases[0].DataSources[0].ConnectionString


that prints out:




Connection Timeout=60;User Id=someID;Data Source=10.10.10.10;Persist Security Info=True




its appears to be the connection string for Database8



cool, so then we should be able to do this as well:



$Analysis_Server.Databases[1].DataSources[0].ConnectionString


However, nothing prints! the only index that seems to print is with Databases[0]



This is what $Analysis_Server.Databases[0].DataSources[0] prints:



DataSources0



we should be able to do the same for all databases



$Analysis_Server.Databases[1].DataSources[0]



$Analysis_Server.Databases[2].DataSources[0]
etc..



but nothing gets printed!










share|improve this question















I am trying to get the connection string of a database datasource with the following script:



 $Analysis_Server = New-Object Microsoft.AnalysisServices.Server 
$Analysis_Server.connect("$server")

$database = $Analysis_Server.Databases[7]
$c = $database.DataSources[0].ConnectionString
$c


nothing is outputting.



I have tried debugging like so:



$Analysis_Server.Databases


this prints out all databases on the server



if i index it $Analysis_Server.Databases, it prints whatever database is indexed (so in my case, 7, prints database8)



clearly the Database property is working.



-------------UPDATE:--------------



here is how the Databases look in the server



server1_Databses



here is what each of the following lines does:



 $Analysis_Server.Databases


this prints out



Databses



One thing one can notice is for some reason they are printed out not in order of how they are on the analysis server as in the picture...I dont know why that is the case



this is what this command prints out:



Analysis_Server.Databases[0]


Database8



Now since index 0 worked, we should be able to index [1], [2], etc...



so the following



Analysis_Server.Databases[1] 
Analysis_Server.Databases[2]


prints:



databases1 and 3



Now unto the connection string:



$Analysis_Server.Databases[0].DataSources[0].ConnectionString


that prints out:




Connection Timeout=60;User Id=someID;Data Source=10.10.10.10;Persist Security Info=True




its appears to be the connection string for Database8



cool, so then we should be able to do this as well:



$Analysis_Server.Databases[1].DataSources[0].ConnectionString


However, nothing prints! the only index that seems to print is with Databases[0]



This is what $Analysis_Server.Databases[0].DataSources[0] prints:



DataSources0



we should be able to do the same for all databases



$Analysis_Server.Databases[1].DataSources[0]



$Analysis_Server.Databases[2].DataSources[0]
etc..



but nothing gets printed!







sql sql-server powershell azure-analysis-services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 30 at 17:26

























asked Oct 29 at 1:49









Cataster

13111




13111











  • you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
    – Paul
    Oct 29 at 9:47










  • @Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
    – Cataster
    Oct 29 at 12:25











  • Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
    – thom schumacher
    Oct 30 at 14:20










  • @thomschumacher please check my UPDATE section
    – Cataster
    Oct 30 at 17:26






  • 1




    @thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
    – Cataster
    Oct 31 at 16:34
















  • you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
    – Paul
    Oct 29 at 9:47










  • @Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
    – Cataster
    Oct 29 at 12:25











  • Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
    – thom schumacher
    Oct 30 at 14:20










  • @thomschumacher please check my UPDATE section
    – Cataster
    Oct 30 at 17:26






  • 1




    @thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
    – Cataster
    Oct 31 at 16:34















you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
– Paul
Oct 29 at 9:47




you should add the info that the connectionstring prints fine on other dbs on that server, or is that not the case anymore? also add some sql tags to get some sql people to look at this
– Paul
Oct 29 at 9:47












@Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
– Cataster
Oct 29 at 12:25





@Paul, ya no matter what, it's only printing with indexes [0] only. Any other index ...nothing. it doesnt make sense at all. Not only that, but when index is 0, its somehow printing the last database (i.e. database8), instead of database 1, since logically 0 is the first index! This looks broken to me/bug. I'll take your suggestion and add more tags ...
– Cataster
Oct 29 at 12:25













Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
– thom schumacher
Oct 30 at 14:20




Looks to be this class... docs.microsoft.com/en-us/dotnet/api/… Can you provide some of the data that you get?
– thom schumacher
Oct 30 at 14:20












@thomschumacher please check my UPDATE section
– Cataster
Oct 30 at 17:26




@thomschumacher please check my UPDATE section
– Cataster
Oct 30 at 17:26




1




1




@thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
– Cataster
Oct 31 at 16:34




@thomschumacher apparently we can receive direct MS support since our team is tied to MS products. I opened a support case and an engineer will be assigned to help me resolve this issue. ill update this post of course once i get answers!
– Cataster
Oct 31 at 16:34












3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










I just played with things a little more, to make sure I understood the issue that you are facing. On the same box, still with the newest available SqlServer PowerShell module loaded - I get these results.



PS C:UsersAdministrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
PS C:UsersAdministrator> $Analysis_Server.connect("AX2012R2A")
PS C:UsersAdministrator> $Analysis_Server.Databases

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast ps Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast Accuracy initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Dynamics AX initial Processed ReadWrite


Now I traverse every database and their datasources, to display the connection string



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_3
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5


And the one-liner that just gives you the connection string and nothing else



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources 
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5


Could you take the time and try to install the latest SqlServer PowerShell module and see if that makes any difference for you and the problem that you are facing?






share|improve this answer




















  • Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
    – Cataster
    Nov 10 at 15:40











  • On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
    – Mötz
    Nov 10 at 16:04











  • Oh ok I'll try that, thanks!
    – Cataster
    Nov 10 at 16:07










  • question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
    – Cataster
    Nov 10 at 16:55










  • That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
    – Mötz
    Nov 10 at 19:38

















up vote
1
down vote













Not saying that I have an answer for you, but I think you can use another approach to get what you need, while waiting for Microsoft support.



I'm working on a AX 2012 demo system, that is running SQL Server 2014. It has several olap databases inside the same instance. I've edited all datasources to point to a different database, to show that we get the correct details out.



I installed the latest SQL Server PowerShell module while testing this.



Install-Module SqlServer -Force -Confirm:$false
Import-Module SqlServer


Now you should have a new PowerShell provider, that enables you to traverse the SQL Server as was it a file system



Get-PSProvider

Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions HKLM, HKCU
Alias ShouldProcess Alias
Environment ShouldProcess Env
FileSystem Filter, ShouldProcess, Credentials C, E, A, D...
Function ShouldProcess Function
Variable ShouldProcess Variable
SqlServer Credentials SQLSERVER
Certificate ShouldProcess Cert
WSMan Credentials WSMan


With that in our hand, you should be able to do the following, that should produce the correct results



#Connect to the SSAS part of the sql server 
PS C:UsersAdministrator> cd SQLSERVER:SQLAS

#List all local instances
PS SQLSERVER:SQLAS> dir

Host Name
---------
AX2012R2A
HTTP_DS

#Connect to the server (local) - you should be able to type in a valid network name
PS SQLSERVER:SQLAS> cd AX2012R2A

#List all instances on that server
PS SQLSERVER:SQLASAX2012R2A> dir

Instance Name
-------------
DEFAULT
POWERPIVOT
TABULAR

#Connect to the default instance on the server you are connected to
PS SQLSERVER:SQLASAX2012R2A> cd default

#List all available collections / areas
PS SQLSERVER:SQLASAX2012R2Adefault> dir

#Connect to the databases area
PS SQLSERVER:SQLASAX2012R2Adefault> cd databases

#List all databases that are available
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> dir

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Getting the same result with Get-ChildItem
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Traverse all databases and show their connection string details
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=MicrosoftDynamicsAX
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6

PS SQLSERVER:sqlasax2012r2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6


I would say that this should get you going, because you can now trust that you have the correct connection string details. I relation to your other question - this should give you all the details for the alter script that you want to produce, so you supply the entire alter statement as the SQL Server expects from you.






share|improve this answer




















  • Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
    – Cataster
    Nov 10 at 15:35










  • 1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
    – Mötz
    Nov 10 at 15:56


















up vote
0
down vote













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







share|improve this answer




















  • so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
    – Cataster
    Oct 30 at 18:32











  • i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
    – Cataster
    Oct 30 at 18:46











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53037741%2fconnectionstring-property-not-printing-connection-string%23new-answer', 'question_page');

);

Post as a guest






























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










I just played with things a little more, to make sure I understood the issue that you are facing. On the same box, still with the newest available SqlServer PowerShell module loaded - I get these results.



PS C:UsersAdministrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
PS C:UsersAdministrator> $Analysis_Server.connect("AX2012R2A")
PS C:UsersAdministrator> $Analysis_Server.Databases

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast ps Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast Accuracy initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Dynamics AX initial Processed ReadWrite


Now I traverse every database and their datasources, to display the connection string



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_3
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5


And the one-liner that just gives you the connection string and nothing else



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources 
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5


Could you take the time and try to install the latest SqlServer PowerShell module and see if that makes any difference for you and the problem that you are facing?






share|improve this answer




















  • Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
    – Cataster
    Nov 10 at 15:40











  • On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
    – Mötz
    Nov 10 at 16:04











  • Oh ok I'll try that, thanks!
    – Cataster
    Nov 10 at 16:07










  • question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
    – Cataster
    Nov 10 at 16:55










  • That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
    – Mötz
    Nov 10 at 19:38














up vote
1
down vote



accepted










I just played with things a little more, to make sure I understood the issue that you are facing. On the same box, still with the newest available SqlServer PowerShell module loaded - I get these results.



PS C:UsersAdministrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
PS C:UsersAdministrator> $Analysis_Server.connect("AX2012R2A")
PS C:UsersAdministrator> $Analysis_Server.Databases

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast ps Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast Accuracy initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Dynamics AX initial Processed ReadWrite


Now I traverse every database and their datasources, to display the connection string



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_3
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5


And the one-liner that just gives you the connection string and nothing else



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources 
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5


Could you take the time and try to install the latest SqlServer PowerShell module and see if that makes any difference for you and the problem that you are facing?






share|improve this answer




















  • Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
    – Cataster
    Nov 10 at 15:40











  • On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
    – Mötz
    Nov 10 at 16:04











  • Oh ok I'll try that, thanks!
    – Cataster
    Nov 10 at 16:07










  • question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
    – Cataster
    Nov 10 at 16:55










  • That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
    – Mötz
    Nov 10 at 19:38












up vote
1
down vote



accepted







up vote
1
down vote



accepted






I just played with things a little more, to make sure I understood the issue that you are facing. On the same box, still with the newest available SqlServer PowerShell module loaded - I get these results.



PS C:UsersAdministrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
PS C:UsersAdministrator> $Analysis_Server.connect("AX2012R2A")
PS C:UsersAdministrator> $Analysis_Server.Databases

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast ps Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast Accuracy initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Dynamics AX initial Processed ReadWrite


Now I traverse every database and their datasources, to display the connection string



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_3
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5


And the one-liner that just gives you the connection string and nothing else



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources 
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5


Could you take the time and try to install the latest SqlServer PowerShell module and see if that makes any difference for you and the problem that you are facing?






share|improve this answer












I just played with things a little more, to make sure I understood the issue that you are facing. On the same box, still with the newest available SqlServer PowerShell module loaded - I get these results.



PS C:UsersAdministrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
PS C:UsersAdministrator> $Analysis_Server.connect("AX2012R2A")
PS C:UsersAdministrator> $Analysis_Server.Databases

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast ps Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast Accuracy initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Dynamics AX initial Processed ReadWrite


Now I traverse every database and their datasources, to display the connection string



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_3
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5


And the one-liner that just gives you the connection string and nothing else



PS C:UsersAdministrator> $Analysis_Server.Databases | ForEach-Object $_.datasources 
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5


Could you take the time and try to install the latest SqlServer PowerShell module and see if that makes any difference for you and the problem that you are facing?







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 11:15









Mötz

66259




66259











  • Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
    – Cataster
    Nov 10 at 15:40











  • On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
    – Mötz
    Nov 10 at 16:04











  • Oh ok I'll try that, thanks!
    – Cataster
    Nov 10 at 16:07










  • question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
    – Cataster
    Nov 10 at 16:55










  • That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
    – Mötz
    Nov 10 at 19:38
















  • Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
    – Cataster
    Nov 10 at 15:40











  • On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
    – Mötz
    Nov 10 at 16:04











  • Oh ok I'll try that, thanks!
    – Cataster
    Nov 10 at 16:07










  • question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
    – Cataster
    Nov 10 at 16:55










  • That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
    – Mötz
    Nov 10 at 19:38















Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
– Cataster
Nov 10 at 15:40





Woah... this might make a difference! ForEach-Object $_.datasources .....the only issue is how could I specifically target a database? For example, like this: $database = $Analysis_Server.Databases[7]
– Cataster
Nov 10 at 15:40













On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
– Mötz
Nov 10 at 16:04





On mobile, so bare with me. You would need to fill in a where-object in the pipeline. "....databases | where-object Name -Like "*NAMEOFDB*" | ForEach-Object...."
– Mötz
Nov 10 at 16:04













Oh ok I'll try that, thanks!
– Cataster
Nov 10 at 16:07




Oh ok I'll try that, thanks!
– Cataster
Nov 10 at 16:07












question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
– Cataster
Nov 10 at 16:55




question: how can I change the connection string? This code retrieves the connection strings, but now how can I set for example the userID or password to something else?
– Cataster
Nov 10 at 16:55












That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
– Mötz
Nov 10 at 19:38




That is the other question 😉 Now we have this one somewhat solved - right? I will give the other question a look tomorrow evening local CET time...
– Mötz
Nov 10 at 19:38












up vote
1
down vote













Not saying that I have an answer for you, but I think you can use another approach to get what you need, while waiting for Microsoft support.



I'm working on a AX 2012 demo system, that is running SQL Server 2014. It has several olap databases inside the same instance. I've edited all datasources to point to a different database, to show that we get the correct details out.



I installed the latest SQL Server PowerShell module while testing this.



Install-Module SqlServer -Force -Confirm:$false
Import-Module SqlServer


Now you should have a new PowerShell provider, that enables you to traverse the SQL Server as was it a file system



Get-PSProvider

Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions HKLM, HKCU
Alias ShouldProcess Alias
Environment ShouldProcess Env
FileSystem Filter, ShouldProcess, Credentials C, E, A, D...
Function ShouldProcess Function
Variable ShouldProcess Variable
SqlServer Credentials SQLSERVER
Certificate ShouldProcess Cert
WSMan Credentials WSMan


With that in our hand, you should be able to do the following, that should produce the correct results



#Connect to the SSAS part of the sql server 
PS C:UsersAdministrator> cd SQLSERVER:SQLAS

#List all local instances
PS SQLSERVER:SQLAS> dir

Host Name
---------
AX2012R2A
HTTP_DS

#Connect to the server (local) - you should be able to type in a valid network name
PS SQLSERVER:SQLAS> cd AX2012R2A

#List all instances on that server
PS SQLSERVER:SQLASAX2012R2A> dir

Instance Name
-------------
DEFAULT
POWERPIVOT
TABULAR

#Connect to the default instance on the server you are connected to
PS SQLSERVER:SQLASAX2012R2A> cd default

#List all available collections / areas
PS SQLSERVER:SQLASAX2012R2Adefault> dir

#Connect to the databases area
PS SQLSERVER:SQLASAX2012R2Adefault> cd databases

#List all databases that are available
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> dir

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Getting the same result with Get-ChildItem
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Traverse all databases and show their connection string details
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=MicrosoftDynamicsAX
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6

PS SQLSERVER:sqlasax2012r2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6


I would say that this should get you going, because you can now trust that you have the correct connection string details. I relation to your other question - this should give you all the details for the alter script that you want to produce, so you supply the entire alter statement as the SQL Server expects from you.






share|improve this answer




















  • Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
    – Cataster
    Nov 10 at 15:35










  • 1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
    – Mötz
    Nov 10 at 15:56















up vote
1
down vote













Not saying that I have an answer for you, but I think you can use another approach to get what you need, while waiting for Microsoft support.



I'm working on a AX 2012 demo system, that is running SQL Server 2014. It has several olap databases inside the same instance. I've edited all datasources to point to a different database, to show that we get the correct details out.



I installed the latest SQL Server PowerShell module while testing this.



Install-Module SqlServer -Force -Confirm:$false
Import-Module SqlServer


Now you should have a new PowerShell provider, that enables you to traverse the SQL Server as was it a file system



Get-PSProvider

Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions HKLM, HKCU
Alias ShouldProcess Alias
Environment ShouldProcess Env
FileSystem Filter, ShouldProcess, Credentials C, E, A, D...
Function ShouldProcess Function
Variable ShouldProcess Variable
SqlServer Credentials SQLSERVER
Certificate ShouldProcess Cert
WSMan Credentials WSMan


With that in our hand, you should be able to do the following, that should produce the correct results



#Connect to the SSAS part of the sql server 
PS C:UsersAdministrator> cd SQLSERVER:SQLAS

#List all local instances
PS SQLSERVER:SQLAS> dir

Host Name
---------
AX2012R2A
HTTP_DS

#Connect to the server (local) - you should be able to type in a valid network name
PS SQLSERVER:SQLAS> cd AX2012R2A

#List all instances on that server
PS SQLSERVER:SQLASAX2012R2A> dir

Instance Name
-------------
DEFAULT
POWERPIVOT
TABULAR

#Connect to the default instance on the server you are connected to
PS SQLSERVER:SQLASAX2012R2A> cd default

#List all available collections / areas
PS SQLSERVER:SQLASAX2012R2Adefault> dir

#Connect to the databases area
PS SQLSERVER:SQLASAX2012R2Adefault> cd databases

#List all databases that are available
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> dir

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Getting the same result with Get-ChildItem
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Traverse all databases and show their connection string details
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=MicrosoftDynamicsAX
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6

PS SQLSERVER:sqlasax2012r2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6


I would say that this should get you going, because you can now trust that you have the correct connection string details. I relation to your other question - this should give you all the details for the alter script that you want to produce, so you supply the entire alter statement as the SQL Server expects from you.






share|improve this answer




















  • Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
    – Cataster
    Nov 10 at 15:35










  • 1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
    – Mötz
    Nov 10 at 15:56













up vote
1
down vote










up vote
1
down vote









Not saying that I have an answer for you, but I think you can use another approach to get what you need, while waiting for Microsoft support.



I'm working on a AX 2012 demo system, that is running SQL Server 2014. It has several olap databases inside the same instance. I've edited all datasources to point to a different database, to show that we get the correct details out.



I installed the latest SQL Server PowerShell module while testing this.



Install-Module SqlServer -Force -Confirm:$false
Import-Module SqlServer


Now you should have a new PowerShell provider, that enables you to traverse the SQL Server as was it a file system



Get-PSProvider

Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions HKLM, HKCU
Alias ShouldProcess Alias
Environment ShouldProcess Env
FileSystem Filter, ShouldProcess, Credentials C, E, A, D...
Function ShouldProcess Function
Variable ShouldProcess Variable
SqlServer Credentials SQLSERVER
Certificate ShouldProcess Cert
WSMan Credentials WSMan


With that in our hand, you should be able to do the following, that should produce the correct results



#Connect to the SSAS part of the sql server 
PS C:UsersAdministrator> cd SQLSERVER:SQLAS

#List all local instances
PS SQLSERVER:SQLAS> dir

Host Name
---------
AX2012R2A
HTTP_DS

#Connect to the server (local) - you should be able to type in a valid network name
PS SQLSERVER:SQLAS> cd AX2012R2A

#List all instances on that server
PS SQLSERVER:SQLASAX2012R2A> dir

Instance Name
-------------
DEFAULT
POWERPIVOT
TABULAR

#Connect to the default instance on the server you are connected to
PS SQLSERVER:SQLASAX2012R2A> cd default

#List all available collections / areas
PS SQLSERVER:SQLASAX2012R2Adefault> dir

#Connect to the databases area
PS SQLSERVER:SQLASAX2012R2Adefault> cd databases

#List all databases that are available
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> dir

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Getting the same result with Get-ChildItem
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Traverse all databases and show their connection string details
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=MicrosoftDynamicsAX
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6

PS SQLSERVER:sqlasax2012r2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6


I would say that this should get you going, because you can now trust that you have the correct connection string details. I relation to your other question - this should give you all the details for the alter script that you want to produce, so you supply the entire alter statement as the SQL Server expects from you.






share|improve this answer












Not saying that I have an answer for you, but I think you can use another approach to get what you need, while waiting for Microsoft support.



I'm working on a AX 2012 demo system, that is running SQL Server 2014. It has several olap databases inside the same instance. I've edited all datasources to point to a different database, to show that we get the correct details out.



I installed the latest SQL Server PowerShell module while testing this.



Install-Module SqlServer -Force -Confirm:$false
Import-Module SqlServer


Now you should have a new PowerShell provider, that enables you to traverse the SQL Server as was it a file system



Get-PSProvider

Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions HKLM, HKCU
Alias ShouldProcess Alias
Environment ShouldProcess Env
FileSystem Filter, ShouldProcess, Credentials C, E, A, D...
Function ShouldProcess Function
Variable ShouldProcess Variable
SqlServer Credentials SQLSERVER
Certificate ShouldProcess Cert
WSMan Credentials WSMan


With that in our hand, you should be able to do the following, that should produce the correct results



#Connect to the SSAS part of the sql server 
PS C:UsersAdministrator> cd SQLSERVER:SQLAS

#List all local instances
PS SQLSERVER:SQLAS> dir

Host Name
---------
AX2012R2A
HTTP_DS

#Connect to the server (local) - you should be able to type in a valid network name
PS SQLSERVER:SQLAS> cd AX2012R2A

#List all instances on that server
PS SQLSERVER:SQLASAX2012R2A> dir

Instance Name
-------------
DEFAULT
POWERPIVOT
TABULAR

#Connect to the default instance on the server you are connected to
PS SQLSERVER:SQLASAX2012R2A> cd default

#List all available collections / areas
PS SQLSERVER:SQLASAX2012R2Adefault> dir

#Connect to the databases area
PS SQLSERVER:SQLASAX2012R2Adefault> cd databases

#List all databases that are available
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> dir

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Getting the same result with Get-ChildItem
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem

Name State Read-Write Mode
---- ----- ---------------
Demand Forecast Accuracy initial Processed ReadWrite
Demand Forecast Accuracy ps Processed ReadWrite
Demand Forecast initial Processed ReadWrite
Demand Forecast ps Processed ReadWrite
Dynamics AX initial Processed ReadWrite
Dynamics AX ps Processed ReadWrite

#Traverse all databases and show their connection string details
PS SQLSERVER:SQLASAX2012R2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources

Name Isolation Max Connections Connection String
---- --------- --------------- -----------------
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_1
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_2
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=MicrosoftDynamicsAX
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_4
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_5
Dynamics Database ReadCommitted 10 Provider=SQLNCLI11.1;Data
Source=AX2012R2A;Integrated
Security=SSPI;Initial
Catalog=DatabaseName_6

PS SQLSERVER:sqlasax2012r2Adefaultdatabases> Get-ChildItem | ForEach-Object $_.Datasources
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_1
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_2
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_3
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_4
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_5
Provider=SQLNCLI11.1;Data Source=AX2012R2A;Integrated Security=SSPI;Initial Catalog=DatabaseName_6


I would say that this should get you going, because you can now trust that you have the correct connection string details. I relation to your other question - this should give you all the details for the alter script that you want to produce, so you supply the entire alter statement as the SQL Server expects from you.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 10:53









Mötz

66259




66259











  • Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
    – Cataster
    Nov 10 at 15:35










  • 1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
    – Mötz
    Nov 10 at 15:56

















  • Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
    – Cataster
    Nov 10 at 15:35










  • 1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
    – Mötz
    Nov 10 at 15:56
















Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
– Cataster
Nov 10 at 15:35




Can you explain to me what the point of knowing the capabilities of PSProvider with Get-PSProvider was? I didnt see anything used from it....also, I have installed the latest sql server just around 1 month ago. I wouldnt think it's the issue since I just installed it recently. Anyways back to your suggestion, I dont understand this part: SQLSERVER:SQLASAX2012R2Adefaultdatabases> is that supposed to be getting in the analysis server? So my server is like this: server1.domain.com. how would I be able to connect to that? Am I supposed to replace SQLSERVER with it?
– Cataster
Nov 10 at 15:35












1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
– Mötz
Nov 10 at 15:56





1. The reason with the Get-PSProvider was to ensure you that the module was loaded and you could see the SqlServer in the list. 2. After the "cd SQLSERVER:SQLAS", you should write "cd server1.domain.com". 3. Everything before the > tag is to show you how powershell is exposing the objects as a file tree structure. You should only care about everything that looks like a ordinary cmd like "cd xyz" and Get-ChildItem
– Mötz
Nov 10 at 15:56











up vote
0
down vote













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







share|improve this answer




















  • so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
    – Cataster
    Oct 30 at 18:32











  • i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
    – Cataster
    Oct 30 at 18:46















up vote
0
down vote













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







share|improve this answer




















  • so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
    – Cataster
    Oct 30 at 18:32











  • i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
    – Cataster
    Oct 30 at 18:46













up vote
0
down vote










up vote
0
down vote









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







share|improve this answer












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








share|improve this answer












share|improve this answer



share|improve this answer










answered Oct 30 at 17:58









thom schumacher

799514




799514











  • so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
    – Cataster
    Oct 30 at 18:32











  • i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
    – Cataster
    Oct 30 at 18:46

















  • so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
    – Cataster
    Oct 30 at 18:32











  • i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
    – Cataster
    Oct 30 at 18:46
















so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
– Cataster
Oct 30 at 18:32





so i have copied that script (from the website) in a whole new powershell file and changed the parameters to my SSAS parameters. i ran the script, refreshed connection/server on SSMS and opened it again and no changes happened to the connection string
– Cataster
Oct 30 at 18:32













i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
– Cataster
Oct 30 at 18:46





i did find that he is passing the database name in the Databases[ ]. so i tried that in my code, i didnt get any errors nor did it get back the connection string. then i tried passing in Database8 and it returned the connection string. i am so frustrated, why is it only printing fine for Database8 (whether its passed as a name or index 0), yet its not working for any of the other DB's.....
– Cataster
Oct 30 at 18:46


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53037741%2fconnectionstring-property-not-printing-connection-string%23new-answer', 'question_page');

);

Post as a guest














































































這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto