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
Show parent comment
2
u/PinchesTheCrab Feb 27 '26
You shouldn't have to restart the session, just importing the updated module should do it. You'll have to use -force since the default behavior is not to import if a module with the same name is already loaded.
That being said, if you're using classes you may have to reload the session if you are loading them directly and not via import-module, depending on how your menu works.