locked
Best Practice PSModulePath RRS feed

  • Question

  • Hi!

    Writing a script for a customer. I've made a custom path and included it in the system and user PSModulePaths everywhere. Works fine. 

    Seconding myself, why not put the modules in the common paths, e.g. C:\Program Files\WindowsPowerShell\Modules ?

    What is best practice actually? Use the standard paths, or create your own? Less configuring with the standard ones of course...leaning towards that.

    Cheers

    Wednesday, March 11, 2020 2:08 PM

All replies

  • The PowerShell Best Practices and Style Guide

    Is there any disadvantage in using the standard paths? If the answer is "No" you have your answer.  ;-)


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Wednesday, March 11, 2020 3:14 PM
  • You should not really use the system module path.  The correct path is the one in "Program Files".  If the module is for only one script solution then just put it in the scripts folder and load it explicitly with the path.

    Import-Module -FullyQualifiedName .\modules\MyModule\MyModule.psd1

    This avoids altering the system for a single utility module.


    \_(ツ)_/

    Wednesday, March 11, 2020 4:00 PM