r/PowerShell • u/CryktonVyr • Feb 27 '26
Question on Best Practices
Hello Veterans of Powershell.
A bit of context. Over the last 2 years, I made a couple of Scripts that originaly I kept in seperate PS1 file and used them when needed. Then I learned how to make terminal menus and functions. Now I have 1 huge PS1 file with 140 functions that enable me to navigate from a Main Menu to sub menus, see results on the terminal window and/or export the results to CSV files or Out-Gridview.
I recently read that this is not aligned with best practices. I should instead have a PS1 file per function and call each file instead.
Why though? I feel like I'm missing some context or good team working habits perhaps?
I'm the only one scripting in an IT team of 3 and my colleague using it just uses the menu options as intended.
EDIT: Since I'm getting the suggestion. I already use a custom module file, a custom $profile and custom $global configuration. It's a "work in progress mess" that became bigger over time.
View all comments
2
u/Kirsh1793 Feb 27 '26
Best practices are just guidelines. In your case, I think there are a few things to consider for your tool.
Personally, I would create a module. You could still use a controller script to start the tool which then loads the module. Ideally the module could also be used independently of the controller script. This way, you could even have multiple ways to use the tool or easily change the UI. Consider making multiple modules to group functions with similar intent. But you will have to figure out how to distribute it.