Rudolph's First PowerShell Module
Overview
This week I presented a Festive Tech Calendar 2023 session about building a PowerShell Module. This post includes a link to the session recording and some accompanying resources. See this and many other sessions on the FestiveTechCalendar.com website and YouTube Channel.
Thanks to the Festive Tech Calendar team for putting this event on again this year.
Session
Rudolph the Red-Nose Reindeer is well known for having a very shiny nose, but he also has a lot of PowerShell scripts and functions that he’d like to share with his reindeer friends. Join our friendly caribou as he packages this code into his first PowerShell Module and shares it with Dasher, Dancer, and the other reindeer.
Or, if you’re watching this the other 11 months of the year, find out how to create a shareable PowerShell module from your existing functions.
Code
The example code used to create Rudolph’s module can be found on Github
PowerShell from Demos
1# List all the available Modules
2Get-Module -ListAvailable
3#Find the Module that Get-Item belongs to
4Get-Command Get-Item
5Get-Module -ListAvailable Microsoft.PowerShell.Management
6#Find all the Azure Modules
7Get-Module -ListAvailable Az.*
1# Generate function Manifest
2New-ModuleManifest -Path .\RudolphsTools.psd1 `
3 -NestedModules @('.\Get-ChristmasTree.psm1', '.\Get-DaysTillChristmas.psm1', '.\Get-ExampleNaughtyList.psm1', '.\Get-NextChristmasDate.psm1') `
4 -Guid (New-Guid) `
5 -ModuleVersion '0.0.0.1' `
6 -PowerShellVersion $PSVersionTable.PSVersion.ToString() `
7 -FunctionsToExport @('Get-ChristmasTree', 'Get-DaysTillChristmas', 'Get-ExampleNaughtyList', 'Get-NextChristmasDate')
1#Import the new Module
2Import-Module .\RudolphsTools.psd1
3#Get all the Commands in the new module
4Get-Command -Module RudolphsTools