Exercise: Share Your Module
Get the RecipeBox module ready to share with a new version number, a README and the MIT License, publish it to a practice repository with Publish-PSResource, and a Pester check opens the package the way a friend would and makes sure it works.
Journeyman · PowerShell · Updated
Your recipe box has grown a new command, Get-RecipeCategory, and a friend who cooks wants it. You could send the folder with a note, or you could hand it over the way every module you've installed came to you: with a version number that says what changed, a README that says how to use it, a license that says what they may do with it, and a package they can install. In this exercise you do the second, and a check opens your package the way your friend would, to make sure it works.
Get the exercise code
Open this lesson's GitHub repository, github.com/ask-codey/exercise-powershell-share-your-module, also linked from the Exercise box beside the lesson. Click Code, then Download ZIP, and unzip it into your terminal-practice folder. Or clone it with Git.
The folder holds:
RecipeBox\: the module from Exercise: Test Your Tool, withGet-RecipeCategoryadded toRecipeBox.psm1. Its manifest still says 1.0.0 and shares only the first three commands. Don't change the.psm1.licenses\MIT.txt: the MIT License, with[year]and[fullname]to fill in.practice-repo\: an empty folder to publish into.RecipeBox.Tests.ps1: your tests from Exercise: Test Your Tool, with one more forGet-RecipeCategory.Check.Tests.ps1: the check. You don't need to change it.
What to do
Open PowerShell 7 in the exercise folder, the one with Check.Tests.ps1 in it. Every step is one you saw in Sharing Your Tool.
A new version. A new command that leaves the old ones working raises MINOR, so this is 1.1.0. Use
Update-PSModuleManifestonRecipeBox\RecipeBox.psd1with-ModuleVersion,-FunctionsToExportwith all four commands, and-ReleaseNoteswith a sentence that namesGet-RecipeCategory. Then runInvoke-Pester .\RecipeBox.Tests.ps1: the test for the new command, red until now, turns green, and all seven pass.A README. Write
RecipeBox\README.md: the title# RecipeBox, what it does, an## Installsection withInstall-PSResource -Name RecipeBox, an## Examplesection with a line or two that use the module's commands, and a## Licensesection that says it's MIT.A license. Copy
licenses\MIT.txttoRecipeBox\LICENSE, with no extension, and replace[year] [fullname]with the year and your name. Leave the rest word for word.Publish it. Register the
practice-repofolder asPracticeRepo, publishRecipeBoxthere, and find it withFind-PSResource:Register-PSResourceRepository -Name PracticeRepo -Uri "$PWD\practice-repo" -Trusted Publish-PSResource -Path .\RecipeBox -Repository PracticeRepo Find-PSResource -Name RecipeBox -Repository PracticeRepoClean up. Run
Unregister-PSResourceRepository -Name PracticeRepo, so your account doesn't keep a practice repository it no longer needs. The folder and the package stay.
Check your work
The check uses Pester. If you haven't installed it yet, install it once:
Install-PSResource Pester
Then, from the exercise folder:
Invoke-Pester .\Check.Tests.ps1
At first all twelve tests fail. That's expected: each step turns some of them green. The last two unzip your package into a throwaway folder, load RecipeBox from it and run Get-RecipeCategory, which is what installing it on a friend's computer would do. A failing test says what it looked for, for example the copyright line reads like Copyright (c) 2026 Sam.
If PowerShell says the check can't be loaded because it is not digitally signed, Windows has marked the downloaded files as coming from the internet: from the exercise folder, run Get-ChildItem -Recurse | Unblock-File once, then try again.
Hints
- Which part goes up? A fix raises PATCH, something new MINOR, a change that breaks a script MAJOR. A new command is something new.
- All four, every time.
-FunctionsToExportreplaces the list, so nameGet-Recipe,Add-Recipe,Remove-RecipeandGet-RecipeCategorytogether. - Inside the box. The README and the LICENSE go in the
RecipeBoxfolder, beside the manifest. Only that folder goes into the package. - Published too soon? Fix the file and publish again: in a practice folder, the new package replaces the one with the same version.
- Code in a README. A line indented by four spaces is shown as code:
Get-RecipeCategory.
When you're done
Every test is green, and Pester's last line says:
Tests Passed: 12, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 0
Now think one version ahead. Next month you fix a typo in a message Remove-Recipe prints: what's the new version number? And if you renamed Get-Recipe to Find-Recipe, which part would go up, and what should the release notes warn your friend about?
Submit your exercise
The exercise is how you finish this lesson. When your work is done, put it on GitHub in a repo of your own, then submit that repo's address here.
On GitHub, click +, then New repository. Name it (for example
exercise-powershell-share-your-module), choose Public, and click Create repository. Leave out the README: your folder already has one.In a terminal in your exercise folder (PowerShell works), send your work to your new repo. If you downloaded the ZIP:
git init -b main git add . git commit -m "My solution" git remote add origin https://github.com/your-name/exercise-powershell-share-your-module.git git push -u origin mainIf you cloned the starter instead, point your copy at your own repo, then commit and push:
git remote set-url origin https://github.com/your-name/exercise-powershell-share-your-module.git git add . git commit -m "My solution" git push -u origin mainPaste your repo's address, such as
https://github.com/your-name/exercise-powershell-share-your-module, into Submit your exercise on this page. The site checks that the repo is public and holds your commits, and then the lesson is complete.
Changed something after you submitted? Push it, and submit again: your latest submission is the one that counts.
That GitHub repo is sharing too: anyone can now read your module, its README and its license, and download it.
Looking back
This is the last lesson of PowerShell in Depth. Your first command in it was Get-Location, to find out where you were. Since then you've found your way around folders without a mouse, rehearsed every delete with -WhatIf before doing it, sorted and filtered objects through the pipeline, turned spreadsheets and web data into reports, made PowerShell your own with a profile, written scripts that are small applications, built commands that behave like PowerShell's own, tested them, looked after Windows, and automated a project. And now you've handed one of your tools to someone else.
You won't remember every parameter, and nobody does. What you have is the habit that finds them: Get-Command to find a command, Get-Help to learn it, Get-Member to see what an object holds, and -WhatIf before anything that can't be undone. The best next project is a problem from your own week, the job you do by hand every Friday, or the folder that's always a mess. A script for it doesn't need to be perfect to save you time.
So what
You started by asking PowerShell where you were, and you finish with a tool of your own that someone else can install, read and trust.