Blog Post

Quick Blog: Making the Power BI PowerShell cmdlets easier to use

,

One of the top reasons I love PowerShell so much is that from the beginning, it was designed to let you, yes you, make it run better for the way you work. In fact, this post from Dmitry
‘freaking’ Sotnikov himself ( blogtwitter ) was probably a turning point, or at least turned up the intensity of why I love PowerShell. There are lots of ways you can take control and make PowerShell easier for you and your co-workers or friends. I won’t list all the options today; I’ll just tell you about one of my favorites: Argument Completers.

Before I go any farther, shout out to Rohn Edwards ( blog | twitter ) for his session at PowerShell Summit which got me started with this. (And then being polite enough to DM back-n-forth with me for like three hours straight while I struggled to get my head around how to make them happen.)

The PowerShell cmdlets for Power BI are extremely useful, but they do have some quirks. I don’t mind the quirks for two reasons:

  1. the cmdlets are open source so we can submit pull requests to fix the quirks.
  2. back to the whole point of this blog, PowerShell lets you make it better, all by yourself!

If you’re trying to use the PowerShell cmdlets for Power BI you may have noticed that the Get-PowerBIReport cmdlet is a little ‘odd’. It allows you to pipe input in from the Get-PowerBIWorkspace cmdlet, which is great, we like that. However, if you to get a list of reports inside a workspace, and you only want to use the Get-PowerBIReport cmdlet, you have to know the Id (a GUID) or have a Workspace object. Neither of those are easy to type out, which is why I whipped up a few Argument Completers instead.

I have the code below in my PowerShell profile so that it’s ready every time I open a PowerShell session. (read more about how to do that here)

Once that’s loaded up, PowerShell will give me a list of Workspaces that I have access to. This makes finding and working with the reports much smoother.

I have 4 other argument completers for the Power BI PowerShell cmdlets in this gist that I think everyone will find handy. Hopefully we can get something like this added to the Power BI modules themselves so you do have to add this on your own. But until then, I hope this makes using the Power BI PowerShell cmdlets much easier for you

BTW, big shout-out to my friend and coworker Caroline Bell (twitter) for reading the Docs files to me about why I couldn’t get this to work the first time I tried

The post Quick Blog: Making the Power BI PowerShell cmdlets easier to use first appeared on SQLvariations: SQL Server, a little PowerShell, maybe some Power BI.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating