# 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 November 10, 2026

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](https://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*, with `Get-RecipeCategory` added to `RecipeBox.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 for `Get-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*.

1. **A new version.** A new command that leaves the old ones working raises MINOR, so this is 1.1.0. Use `Update-PSModuleManifest` on `RecipeBox\RecipeBox.psd1` with `-ModuleVersion`, `-FunctionsToExport` with all four commands, and `-ReleaseNotes` with a sentence that names `Get-RecipeCategory`. Then run `Invoke-Pester .\RecipeBox.Tests.ps1`: the test for the new command, red until now, turns green, and all seven pass.
2. **A README.** Write `RecipeBox\README.md`: the title `# RecipeBox`, what it does, an `## Install` section with `Install-PSResource -Name RecipeBox`, an `## Example` section with a line or two that use the module's commands, and a `## License` section that says it's MIT.
3. **A license.** Copy `licenses\MIT.txt` to `RecipeBox\LICENSE`, with no extension, and replace `[year] [fullname]` with the year and your name. Leave the rest word for word.
4. **Publish it.** Register the `practice-repo` folder as `PracticeRepo`, publish `RecipeBox` there, and find it with `Find-PSResource`:

   ```powershell
   Register-PSResourceRepository -Name PracticeRepo -Uri "$PWD\practice-repo" -Trusted
   Publish-PSResource -Path .\RecipeBox -Repository PracticeRepo
   Find-PSResource -Name RecipeBox -Repository PracticeRepo
   ```

5. **Clean 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:

```powershell
Install-PSResource Pester
```

Then, from the exercise folder:

```powershell
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.** `-FunctionsToExport` replaces the list, so name `Get-Recipe`, `Add-Recipe`, `Remove-Recipe` and `Get-RecipeCategory` together.
- **Inside the box.** The README and the LICENSE go in the `RecipeBox` folder, 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:

```text
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.

1. 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.
2. In a terminal in your exercise folder (PowerShell works), send your work to your new repo. If you downloaded the ZIP:

   ```powershell
   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 main
   ```

   If you cloned the starter instead, point your copy at your own repo, then commit and push:

   ```powershell
   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 main
   ```

3. Paste 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.

## Key terms

- [README](https://www.ask-codey.com/glossary/readme)
- [Software License](https://www.ask-codey.com/glossary/software-license)
- [Semantic Versioning](https://www.ask-codey.com/glossary/semantic-versioning)
- [Publish-PSResource](https://www.ask-codey.com/glossary/publish-psresource)
- [Module Manifest](https://www.ask-codey.com/glossary/module-manifest)

## Related

- [Sharing Your Tool](https://www.ask-codey.com/lessons/powershell-sharing-your-tool)
- [Your Own Module](https://www.ask-codey.com/lessons/powershell-modules)
- [Exercise: Test Your Tool](https://www.ask-codey.com/lessons/exercise-powershell-test-your-tool)
- [When to Reach for Another Language](https://www.ask-codey.com/lessons/powershell-when-to-use-another-language)

Source: https://www.ask-codey.com/lessons/exercise-powershell-share-your-module
