Script and Module Best Practice question

I wrote a module with a bunch of functions and I also wrote several tools that use those functions. The tools are also functions. I need to share the module and tools with my team and I want the tools to be easy to access so I added them to the module. That allows a user to type verb-toolname and not have to dot source the script from another location to run the tool. I wanted to get others thoughts on this to see what others do or have done.

Yep, that’s the way to do it! Module with all your stuff in it. If you wanted to get really fancy you could look into setting up a private nuget server to host your modules, then you could use stuff like install-module and find-module to download and install the module, rather than dealing with copying your module folder around.

Edit: Also, if you’re not already, now would be a great time to look into putting your module code into some sort of source control system. If you’re in a windows shop maybe check with your devs to see if they use TFS. They can carve you off a team site and set up a GIT repository easily enough.

Thanks, that reassures that my tools can also be in my module.

I created a network module repository and wrote a “setup” script for my team to use to register the repository. I added a script in the module to update modules in the repository once a week. the “setup” script creates a PS profile and adds a line to it to run the update script. So whenever the console runs it will run update-module against all modules that are in the repository.

Source Control is something I really need to get into. I’m not there yet, but its on my moving up list. Platyps is also something I need to work on too.

I had a similar process with a network share, trying to keep it all updated. Your solution sounds better than what I had, seems like whatever I tried just resulted in files all over the place and my session would take forever to load. If you’ve done any downloads from the powershell gallery with the powershellget commands it’s pretty clean.

Find-Module Platyps | install-module -scope currentuser
might be one to try out. You get hooked on that and it’s hard to go back to a network share.

Oh and on the topic of PlatyPS, it’s pretty awesome. If you already have the comment-based help written for each function, it’s literally two commands to convert everything over.

I know the PowerShell Scriting and Toolmaking book covers PlatyPS. I fumbled through using it, but was hoping to find additional documentation about it (tutorials, or guides). Ironically the PlatyPS help documentation seems slim.

For platyPS check out the powershell unplugged video from ignite. PlatyPS demo starts at around minute 7.