PowerShell Studio Feature RequestsFeature requests, product enhancement ideas, and other product-specific suggestions.
In PowerShell Studio be able to run "New Module from Functions" from the command line
cmonahan, Oct. 10, 2017Under Review
Copied from feature requests forum post: https://www.sapien.com/forums/viewtopic.php?f=9&t=11211 .
Ã‚Â I have a lot of utility functions for our VMware environment that I started packaging into a module for convenience, so I didn't have to dot source individual files.Ã‚Â It would also be easier to distribute the functions to the rest of the team.
Ã‚Â I keep all the functions as one function per ps1 file for easy editing and git tracking.Ã‚Â I update individual functions often enough that this would be a time/click saver.
My workflow is:
1- Edit the single file function.ps1
2- Commit to git
3- Run "New Module from Functions" from the gui. (This would be changed to "from the commandline".)
X- Copy the new module files to the file share for general use Ã‚Â --- 10/10/2017- On second thought, this should not be a feature.Ã‚Â It breaks the PowerShell "do one small thing well" principle.
1- Specify a directory with a recurse option for the list of functions to add.
2- Pass a text file of file paths for the list of functions to add.
3- Optional- Maybe a config/project file to specify the options.
4- Be able to set the module version. Optionally auto-increment the version.
5- Add other module manifest information. Maybe the suggested config/project file would be a good place to store that.
6- Optionally update an existing module instead of rebuilding from scratch. Only the function would be replaced and the module version incremented.
10/10/2017 Update- I've expanded my use of modules and the other admins are expanding their use of PowerShell.Ã‚Â This would be a big help.
Comment by Bosparan, Dec. 10, 2017
Hi Chris, while I agree that having some of those features automatable would be nice (my prime pick would be the "format script" functionality), I have to question your approach: Why not make it a module project?
Keeping all those functions in a single file is bound to be a major nuisance from a code maintenance perspective.
Also note that turning a script file with functions into module automatedly shouldn't be hard to build by yourself. If you're at the point of automating it into a CI/CD workflow, you shouldÃ‚Â be able to do it.
Comment by cmonahan, Feb. 9, 2018
Oops.Ã‚Â Didn't see an email that there was a response.
Module Projects don't fit our workflow.Ã‚Â We're SysAdmins that work on one small task at a time that becomes a script or function.Ã‚Â There are few functions that use other functions.Ã‚Â I'm trying to push them all to write functions.Ã‚Â Putting them all into a module is for our convenience.Ã‚Â We don't have to dot source individual files through our profile, and by loading the module we're all using the same tested versions of functions.
I agree.Ã‚Â :)Ã‚Â That's why I want to keep them as separate files.Ã‚Â When a function needs to be worked on we open the one file and test with it, dot sourcing the one file as needed.Ã‚Â When it's ready the module it's in gets rebuilt and pushed out to the file share.
Maybe I could write it myself, but I figured if Sapien had already done it in the GUI it should be that hard to break it out into a command line tool.Ã‚Â I've also seen one attempt at it by a really good .Net developer who moonlights as a really good PowerShell developer and while his script worked, it didn't seem easy and didn't work just the way I wanted it to.Ã‚Â Maybe I'll take another look writing one.
Thanks for the feedback.