Script and Module Best Practice question

This topic contains 5 replies, has 2 voices, and was last updated by  Jeremy Murrah 1 week, 3 days ago.

  • Author
    Posts
  • #81932

    Kevin Greer
    Participant

    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.

  • #81934

    Jeremy Murrah
    Participant

    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.

  • #81962

    Kevin Greer
    Participant

    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.

  • #81967

    Jeremy Murrah
    Participant

    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.

  • #81986

    Kevin Greer
    Participant

    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.

  • #82007

    Jeremy Murrah
    Participant

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

    https://myignite.microsoft.com/videos/54867

You must be logged in to reply to this topic.