我有以下脚本,应该用来更改服务器上数据库的连接字符串
$h = @{}
Import-Csv 'file.csv' | ForEach-Object {
$h += @{$($_.Server) = ($_.Database -split '\s*,\s*') }
}
foreach($server in $h.Keys){
$Analysis_Server = New-Object Microsoft.AnalysisServices.Server
$Analysis_Server.connect("$server")
foreach($db in $h[$server]) {
write-output "$server - has db $db"
$database = $Analysis_Server.Databases.FindByName($db)
####### Setting connection property for $database #######
$database.DataSources[0].ConnectionString = "UserId=…;Password=…."
}
}
我收到以下错误:
在此对象上找不到属性'ConnectionString'。确认该属性存在并且可以设置。
ConnectionInfo文档:https://docs.microsoft.com/it-it/dotnet/api/microsoft.analysisservices.connectioninfo?view=sqlserver-2016