以下脚本在此处具有连接的硬编码名称(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"
答案 0 :(得分:1)
您可以使用AS数据库对象的DataSources
属性
$c.DataSources.Name
$c.DataSources.ConnectionString