PowerShell Potluck April 2025
I hope you learned a few things from this month's content. Let's wrap up with a potluck of PowerShell goodies.
PSPodcast
As I was hanging out at the bar on my last night of The PowerShell Summit, I was chatting with Andrew Pla, who hosts the weekly PowerShell Podcast. We were talking about profile scripts, and somehow ended up with the idea of displaying information about the latest episode when you start PowerShell. This seemed like a fun idea, and I knew this would be a great opportunity to leverage the pwshSpectreConsole
module. I could use the formatting capabilities of the module to create a nice display of the latest episode.
This was a fun project and demonstrates that you can use PowerShell for more than automation and management at scale. You can install the PSPodcast module from the PowerShell Gallery. The module requires PowerShell 7.4 or later. Installation will also install the pwshSpectreConsole
module as a dependency, if not already installed.
Once installed, run Get-PSPodcastModule
to see a summary of the module commands.

You can use the module to get episode information, download episodes, and get show notes.
For the PowerShell profilem you can insert the command Show-LatestPSPodcast -profile
into your profile script. This will display the latest episode once every 24 hours.

The module uses custom formatting and other pwshSpectreConsole features including clickable links. I recommend you look at the project's README file to get started.
Import-LocalModule
I also have another scripting project that takes advantage of the pwshSpectreConsole
module. I have several modules that I have written for personal use. These are not published to the PowerShell Gallery. To use them, I need to run Import-Module
and specify the path. I don't want to copy them to a location in the $env:PSModulePath
environment variable because that adds more work when it comes to updating the modules. I realized I wanted a simple way to import these local modules. I created a function called Import-LocalModule
. The module will prompt me for modules based on data stored in a JSON file.
[
{
"ModuleTitle": "Stripe Tools",
"ModuleName": "StripeTools",
"Path": "c:\\scripts\\StripeTools\\StripeTools.psd1"
},
{
"ModuleTitle": "MuseScore Tools",
"ModuleName": "MuseScoreTools",
"Path": "c:\\scripts\\MuseScoreTools\\MuseScoreTools.psd1"
},
{
"ModuleTitle": "Pluralsight Tools",
"ModuleName": "PluralsightTools",
"Path": "c:\\scripts\\PluralsightTools\\PluralsightTools.psd1"
},
{
"ModuleTitle": "Buttondown Tools",
"ModuleName": "ButtondownTools",
"Path": "c:\\scripts\\ButtondownTools\\ButtondownTools.psd1"
},
{
"ModuleTitle": "Drawing Color Tools",
"ModuleName": "DrawingColorTools",
"Path": "c:\\scripts\\DrawingColorTools.psm1"
},
{
"ModuleTitle": "PSWorkItem",
"ModuleName": "PSWorkItem",
"Path": "c:\\scripts\\PSWorkItem\\PSWorkItem.psd1"
}
]
The function uses Read-SpectreMultiSelection
to generate a pick list as part of a Read-Host
like prompt. Selected items are then imported into my session.
#requires -version 7.5
#requires -module pwshSpectreConsole
Function Import-LocalModule {
[cmdletbinding()]
[alias('ilm')]
Param(
[string]$DataPath = "c:\scripts\localmodules.json",
[switch]$Passthru
)
$data = Get-Content $DataPath | ConvertFrom-json
#use inline formatting supported by pwshSpectreConsole
$splat = @{
Message = "`n[italic Chartreuse1]Select one or more local modules to import[/]"
AllowEmpty = $true
Color = "Chartreuse1"
Choices = $Data
ChoiceLabelProperty = "ModuleTitle"
PageSize = 7
}
$r = Read-SpectreMultiSelection @splat
if ($r) {
$r.Foreach({
Write-SpectreHost "Importing [green italic]$($_.ModuleName)[/] from [green italic]$($_.Path)[/]"
Import-Module -Name $_.path -Force
If ($Passthru) {
Get-Module -Name $_.ModuleName
}
})
}
else {
Write-SpectreHost "[OrangeRed1]No modules selected[/]"
}
}
The function has an alias of ilm
and can be used like this:

After selecting the modules, the function imports them and displays a message.

Currently, I manually edit the JSON file to add or remove modules. I may add a function to do that, but for now, this works for me.
RTPSUG Custom Formatting Presentation
Earlier this Spring, I gave a presentation to the Research Triangle PowerShell User Group (RTPSUG) on custom formatting. I think I previously shared the link to the presentation materials..

The video is now available on the RTPSUG YouTube channel. RTPSUG is a great user group and their meetings are open to anyone.
A New Scripting Challenge
I hope you enjoyed last month's PowerShell scripting challenge. Even if you don't learn anything major, the way to improve your PowerShell scripting is to script PowerShell. For this month's challenge, I want you to take at look at the %PSModulePath%
environment variable. This variable contains a list of paths where PowerShell looks for modules that it can auto-import. For the basic challenge, write a script that will find how many modules are installed in each location defined in %PSModulePath%. The output should show the location and the number of modules installed in that location. For bonus points, include the computername.
For a slightly more advanced challenge, I want you to take into account that you might have multiple versions of the same module installed. You can see this when you look at the module path. Write a PowerShell script or function that enumerates the modules in each %PSModulePath%
location that shows the path, the module name, the total number of module versions, the computer name and user name. Bonus points to add features like Write-Progress
, custom formatting or something from the pwshSpectreConsole module.
Summary
As always, thank you for your support. See you next month.