Ok I have this script, it should be straightforward:
# 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()
And of course it isn't:
Exception calling "Connect" with "1" argument(s): "The connection string is not valid." $server.Connect($connectionString) CategoryInfo : NotSpecified: (:) [], MethodInvocationException FullyQualifiedErrorId : ConnectionException
The funny part is I can do the same thing in C# with the same connection string, without any issues...
using (Server server = new Server())
{
server.Connect(serverConnectionString);
// Collect databases to drop in a separate list
List<Database> databasesToDrop = new List<Database>();
foreach (Database element in server.Databases)
{
databasesToDrop.Add(element);
}
databasesToDrop.AsParallel().ForAll(element =>
{
element.Drop();
});
}
I am at a lose for what the issue is, what is wrong with the connection string?
I've tried messing around with different authentication methods, same issue really, works in c#, doesn't work in powershell...