As in the video that I posted in the comment to your original question, you shouldn't put your modules in the same place where Microsoft puts their modules. (i.e., C:\Windows\System32\WindowsPowershell\v1.0\Modules
)
So where should you put your custom Powershell modules? The answer is simple. You put your modules in one of the directories specified in your PSModulesPath environment variable, that isn't System32\WindowsPowershell\v1.0\Modules
.
PS C:\Users\ryan> $Env:PSModulePath -split ';'
C:\Users\ryan\Documents\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\
Now I know that you only see a user-specific directory up there. But you can add whatever path you want to this environment variable. And you can do it machine-wide, so that it affects all users. You can do this in the GUI by going to Advanced System Properties, or you can do it on the command line using setx
. The set
command is only good for the current session, setx
will set a persistent, system-wide variable.
You could also try putting the PS module in
C:\Users\All Users\Documents\WindowsPowershell\Modules
But I haven't tested that so you might still need to add an environment variable for that directory.
Edit: Lastly, don't forget to create a subdirectory your module, so if your module is named Foo, you need to create the subdirectory Foo under one of those PSModulePaths.
Enjoy your Powershell learning journey! :)