【问题标题】:Get Connection dataSource of Tabular database获取表格数据库的连接数据源
【发布时间】:2018-06-27 15:50:51
【问题描述】:

使用 SQL2017 版本 14.0.1.439。我需要使用 Powershell 更改表格数据库中 Connections 的 dataSource 路径。

这是我的代码:

$ServerName="localhost\tabular"
$loadInfo = 
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$server = New-Object Microsoft.AnalysisServices.Server
$server.connect($ServerName)
if ($server.name -eq $null) {
 Write-Output ("Server '{0}' not found" -f $ServerName)
 break
}
foreach ($d in $server.Databases )
{
Write-Output ( "Database: {0}; Status: {1}; Size: {2}MB; Data Sources: {3} " -f $d.Name, $d.State, ($d.EstimatedSize/1024/1024).ToString("#,##0"), $d.DataSources.Count )
}

我的问题,$d.DataSources.Count 总是 0。

我正在寻找一些用 PS 编辑它的方法。

【问题讨论】:

  • 向我们展示你得到的输出。

标签: sql powershell ssas-tabular sql-server-2017


【解决方案1】:

您应该通过Model.Datasources 访问数据源 我可以确认以下代码返回了我的表格模型的数据源数量。

$ServerName="localhost\tabular"
$loadInfo = 
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

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

if ($server.name -eq $null) {
 Write-Output ("Server '{0}' not found" -f $ServerName)
 break
}
foreach ($d in $server.Databases )
{
     Write-output ( "Database: {0}; Status: {1}; Size: {2}MB; Data Sources: {3} " -f $d.Name, $d.State, ($d.EstimatedSize/1024/1024).ToString("#,##0"), $d.Model.DataSources.Count )
}

【讨论】:

    猜你喜欢
    • 2019-06-22
    • 2017-08-12
    • 2013-04-25
    • 2021-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-27
    • 1970-01-01
    相关资源
    最近更新 更多