ConnectionString property not printing connection string

前端 未结 3 1782
独厮守ぢ
独厮守ぢ 2021-01-23 07:19

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

   $Analysis_Server = New-Object Microsoft.AnalysisServices.Server           


        
3条回答
  •  迷失自我
    2021-01-23 07:58

    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:\Users\Administrator> $Analysis_Server = New-Object Microsoft.AnalysisServices.Server
    PS C:\Users\Administrator> $Analysis_Server.connect("AX2012R2A")
    PS C:\Users\Administrator> $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:\Users\Administrator> $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:\Users\Administrator> $Analysis_Server.Databases | ForEach-Object {$_.datasources | ForEach-Object {$_.ConnectionSt
    ring}}
    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?

提交回复
热议问题