I published a PowerShell Module!

Reading Time: 2 minutes

I’ve been working with Power BI metadata a lot lately. Analysing and sourcing information about the security, content and workspaces we hold and I always found myself re-using authentication code or I’d end up approaching problems differently as my PowerShell skills progressed over the last 12 months. It was a few  months ago that I decided to properly organise the functions I was using and create a PowerShell module. In December, after reading some great material and watching some sessions from Rob Sewell I realised I could publish this to the PowerShell Gallery with a proper CI/CD process to boot!

Here’s the link to the module & the source on GitHub if you want to check it out but I just wanted to highlight and thank all the great people that created guides and sessions which got me there!

PowerShell Gallery: Power BI Metadata Module  |  GitHub: PowerBI-Metadata

Step 1: Get the module framework ready

Creating a PowerShell Module using Plaster (by Rob Sewell)

This was a great guide to get started with building out a module. There’s pester tests built into Rob’s version and the framework is there for you to create your own tests for the functions & scripts you add to the module. I found it really easy to get started.

Step 2: Add to Source Control

I ended up using VSTS for the CI/CD component of this “project” which has Git source control built in but at this point I was already using GitHub which tied in great with this MSDN post I found for VSTS

Continuously publish your PowerShell module to PowerShell Gallery by using GitHub and VSTS (by Kenichiro Nakamura)

Step 3: Create your functions & scripts

This step is really subjective and depends what your module is going to do. I went with creating advanced functions for all the key components I wanted to capture from Power BI and 2 functions for authentication – prompted & unattended to allow automation.

Step 4: Build your Pester tests

Green is Good, Red is Bad – Write your first Pester test today (by Rob Sewell)

Rob presented this session at my event in Glasgow: SQLGLA but with organiser duties I wasn’t able to catch all of it at the time.

Step 5: CI/CD goodness! Automate testing, build & deployment with VSTS

This was my first time using VSTS beyond some basic poking around. Rob gives a great overview in his PSDay session but I had to dive deeper to get things set up. I ended up finding that the documentation on Microsoft was out of date (buttons, settings and pages weren’t where they should have been) but I was able to get there in the end.

CI/CD for Modules to the PowerShell Gallery (with VSTS)

This is just a summary of the resources I used so there’s a lot of detail missing but I wanted to highlight just how easy it is, especially when skilled presenters and bloggers have covered the topics!

Please share any tips or related blogs you may have in the comments! Thanks

 

Craig

 

 

You may also like...

Leave a Reply