So as long as I have my modules in that Modules folder then they are available to me in a freshly open console but they are not actually loaded into memory until I actually run them. So having your profile load the modules is no longer really needed. If I have modules some place other than the default path that PSModulePath looks at then I do need to load them or use my profile to load them. If I remove-module after using it it is no longer loaded into memory but still available to run again because of the PSModulePath. This clears things up for me a lot. I didn’t know they were being made available to the console automatically. I thought they were being loaded into memory somehow.
This helps me greatly in what I want to do. I don’t want anything to run and load into memory from my profile anymore. I want to have a fresh clean shell every time it’s launched. I want to only use some form of writing to the console for information in my profile and have all of my variables, aliases and functions load with each module.
I used to load all of my functions into memory by dot sourcing them and then I had my profile write-host a menu of functions available. I don’t know what the best practice is for profiles, modules and functions but I figured since I am changing everything over to modules I wanted them to only be in memory when they are used. All of my functions are designed for managing computer labs. Some of the functions are for: copying a file, removing files, setting desktop wallpapers, restarting computers, pinging computers, checking for logged on computers, running remote commands on computer, and more… I can chain these together in the pipeline for example I can ping, check if not logged on, restart computer. it will only restart the computer if it’s pingable and no one is logged on. these type of functions and the pipeline are very handy in a computer lab environment.
Thanks for clearing this up for me. I actually searched for a good while and never found anything that clearly explained why the modules would run when I didn’t load them. Now I know why. I have almost all of your books so I will look into this more as well. Maybe I need to go back to PowerShell Toolmaking and review it.