Код: Выделить всё
# Load the Microsoft.AnalysisServices assembly from the NuGet package
$amoPath = (Join-Path (Join-Path $env:USERPROFILE ".nuget\packages\microsoft.analysisservices.tabular") "13.0.2150.3\lib\Microsoft.AnalysisServices.Core.dll")
Add-Type -Path $amoPath
$amoPath = (Join-Path (Join-Path $env:USERPROFILE ".nuget\packages\microsoft.analysisservices.tabular") "13.0.2150.3\lib\Microsoft.AnalysisServices.Tabular.dll")
Add-Type -Path $amoPath
# Connect to the AAS instance
$connectionString = "Provider=MSOLAP;DataSource=asazure://eastus.asazure.windows.net/myservernamehere;User ID=BlahBlah;Password=SuperSecretPassword;Persist Security Info=True;Impersonation Level=Impersonate;"
$server = New-Object Microsoft.AnalysisServices.Tabular.Server
$server.Connect($connectionString)
# Delete all databases in the server
foreach ($database in $server.Databases) {
Write-Host "Deleting database: $($database.Name)"
$database.Drop()
}
# Disconnect from the server
$server.Disconnect()
Исключение, вызывающее «Connect» с аргументами «1» : «Строка соединения
недействительна».
$server.Connect($connectionString)
CategoryInfo : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : ConnectionException
Самое смешное: я могу сделать то же самое на C# с той же строкой подключения, без каких-либо проблем.. .
Код: Выделить всё
using (Server server = new Server())
{
server.Connect(serverConnectionString);
// Collect databases to drop in a separate list
List databasesToDrop = new List();
foreach (Database element in server.Databases)
{
databasesToDrop.Add(element);
}
databasesToDrop.AsParallel().ForAll(element =>
{
element.Drop();
});
}
Я' Я пробовал возиться с разными методами аутентификации, на самом деле та же проблема, работает в C#, не работает в PowerShell...
Подробнее здесь: https://stackoverflow.com/questions/792 ... powershell