Hi I saw this power shell script which can connect to power bi and export more data than the normal limit that is allowed from power bi.
This script works and exports to a csv file from power bi, any ideas if this can be acheived through VBA or any other suggestion of a way to connect to power bi desktop (pbix file) using VBA in order to extract data. Or can VBA call power shell?
The reason i'm asking is to export from power bi. You can export data from power bi desktop but there is a limit. One way around this..is this power shell script ..but can it be done from VBA. I'm more familiar with vba and power shell may require system privileges. There is also a way using language 'r' but im asking if you can do it in VBA R way to export fyi.
# Connect using ADOMD.NET (power shell script)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.AdomdClient")
#[Microsoft.AnalysisServices.AdomdClient.AdomdConnection]
# Create the first connection object
$con = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$con.ConnectionString = "Datasource=$dataSource; Initial Catalog=$Database_Name;timeout=0; connect timeout =0"
$con.Open()
"Datasource= " +$dataSource
"Database_Name= " +$Database_Name
$filename = "Table1.csv"
# Create a command and send a query
$command = $con.CreateCommand()
$command.CommandText = $query
$adapter = New-Object -TypeName Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $command
$dataset = New-Object -TypeName System.Data.DataSet
$adapter.Fill($dataset)
$dataset.Tables[0] | export-csv $filename -notypeinformation
# Close the first connection
$con.Close()