metamoof / powershell-powerbidesktop

Powershell modules for PowerBI Desktop
Other
3 stars 0 forks source link

Create a command to refresh power BI tables. #4

Open metamoof opened 6 years ago

metamoof commented 6 years ago

This suite needs a command to refresh the table.

There is code to do this using AMO on Salvador's update script, which I have pasted below

There probable needs to be a -Save switch.

    #  Connect using AMO thanks for stackexchange Smiley Happy

    log_message "Connecting to PBI using AMO"
    [System.Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.tabular.DLL")
     ("Microsoft.AnalysisServices") >$NULL
    $server = New-Object Microsoft.AnalysisServices.tabular.Server

    $server.connect($dataSource)
    $database = $server.Databases.Item($Database_Name)

    #Refreshing Bower BI (thanks to Marco russo http://www.sqlbi.com/articles/using-process-add-in-tabular-models/)
    log_message "Trying to refresh Power BI now"
    $model = $database.Model
    $model.RequestRefresh("Full")
    $model.SaveChanges()

    $server.disconnect($dataSource)
metamoof commented 6 years ago

What to call it though? PowerBIPS calls the online version Request-PBIDatasetRefresh