I'm a PowerShell newbie so please forgive my ignorance. I have an Azure Analysis Services database, and I'd like to use PowerShell to export data into a CSV file using a DAX query. I want to export the result of this query to a blob storage.
#[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.AdomdClient")
$assemblyPath = "C:\Modules\User\Microsoft.AnalysisServices.AdomdClient\Microsoft.AnalysisServices.AdomdClient.dll"
try {Add-Type -Path $assemblyPath}
catch { $_.Exception.LoaderExceptions }
$Query =
"EVALUATE SUMMARIZECOLUMNS( Dim_AssetClass[Name])"
$ExportPath = "ToMyBlobStorage"
$Connection = New-Object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$Results = New-Object System.Data.DataTable
$Connection.ConnectionString= "Provider=MSOLAP;Data Source=asazure://westeurope.asazure.windows.net/MonTabularModel;User ID=app:xxxxxxxx;Password=xxxxxxx;;Persist Security Info=True;Impersonation Level=Impersonate"
$Connection.Open()
$Adapter = New-Object Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $Query ,$Connection
$Adapter.Fill($Results)
$Results | export-csv -Path $ExportPath -NoTypeInformation
$Connection.Dispose()
$Connection.Close()
But I have error messages. Could someone help me to do it?
Has anyone tried doing something like this before, or am I way off base with what I'm trying to do? Thanks for your help.