正在获取连接 属性 名称

Getting connection property name

此处的以下脚本具有连接的硬编码名称 (TD_NAME)。我想让它成为一个变量,它可以获取服务器中的连接名称。

write-host "Connections folder > TD_NAME > "

例如,在图像中,变量将获取 "Teradata DEV" 名称并将其传递到输出消息中。

这就是我要实现的:

Import-Module SqlServer

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

$c = $as.Databases | Where-Object { $_.ID -eq $Database } #this gets the CUBE to get its relevant connection property

### Here goes whatever the code is that will expand the connection folder (if necessary) and get the connection name ###
#Example: 
# $TD_NAME = c.connectionsomething...

write-host "Processing job failed!`r`nCheck the TD credentials by expanding the CUBE Connections folder > $TD_NAME > Properties > Connection String"

您可以使用 AS 数据库对象的 DataSources 属性

$c.DataSources.Name
$c.DataSources.ConnectionString