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
– Register the Power BI app in Azure.
-Apply permission to your Application in Azure AD
– Install PowerShell module for PowerBI

Register Power BI App.

  1. Go to dev.powerbi.com/app.
  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

Register App in Azure.

  1. Search for App Registration under More Services.
    app registration
  2. Select New application registration.
  3. – Set a name.
    – Select Native type.
    – Set this redirect URI:
    https://login.microsoftonline.com/contoso.onmicrosoft.com/oauth2
    – Create.
    azureapp

 

 

Apply permissions to your appliocation within Azure AD.

  1. Select the newly created app within App Registrations section.
    newlycreated
  2. Select required permissions menu.
    required p
  3. Open the Windows Azure Active Directory API and select “Access the directory as the signed-in  user”. Save.
    azure p.png
  4. Open the Power BI Service API and select all permissions under Delegated Permissions. Save.
    power p.png
  5. 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.

 

One thought on “Integrating PowerShell with PowerBI (Part 1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s