Integrating PowerShell with PowerBI (Part 1)

Power BI is a extremely powerful data and visualization tool. It have opened a new world for me. But the first thing i always think about when taking a look at Microsoft products, there have to be a way to control this with PowerShell. I did not find any good information about any PowerShell module on the product pages.  After some googling i  found a module on the PowerShell gallery that have been created by what i believe is a Micrsoft employee.  What was suprising was that the module have been out for about 7 months and have barely 130 downloads.  Why haven’t this been so popular? Hopefully i can help change this with a series of blog posts looking at the possibilities of Power BI and PowerShell.

First article is going to take a look at what is needed to get started and set up the connection/integration.

What is needed:
–  Azure active directory tenant and organizational user.
– Register an Power BI App
-Apply permission to your Application in Azure AD
– Install PowerShell module for PowerBI

Register Power BI App.

  1. Go to dev.powerbi.com/apps.
  2. Sign in with your existing account.
  3. Set App Name.
  4. For PowerShell use you select Native app.
  5. Enter this as a Redirect URL:
    https://login.microsoftonline.com/{contoso.onmicrosoft.com}/oauth2
  6. Sellect all APIs. Check here for more infoprmation on there permissions:
    https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-power-bi-permissions/
  7. Register App.
  8. Take note of Client ID.

app reg 1

app reg 2

Give app permissions in Azure.

  1. Search for App Registration under More Services.
    app registration

 

 

2. Select the newly created app within App Registrations section.
newlycreated3. Select required permissions menu.
required p4. Open the Windows Azure Active Directory API and select “Access the directory as the signed-in  user”. Save.
azure p.png5. Open the Power BI Service API and select all permissions under Delegated Permissions. Save.
power p.png6. Select Grant Permissions.
grant.png

 

Now its time to install the Power BI module and its dependancies.
Since its on the PowerShell Gallery, its as simple as opening a PowerShell window and enter:

Install-Module -Name Microsoft.ADAL.PowerShell
Install-Module -Name Microsoft.PowerBI.PowerShell

You can read more about the module here:
https://www.powershellgallery.com/packages/Microsoft.PowerBI.PowerShell/1.2

We are now all set to start sending data into Power BI from PowerShell.

In the next part/blog article i will take a look at how we use the Power BI module and how to visualize the data in Power BI reports.

 

2 thoughts on “Integrating PowerShell with PowerBI (Part 1)

Leave a comment