Many PowerShell users start to take a look at PowerShell 7, and run it side-by-side to the built-in Windows PowerShell.

Both PowerShell versions maintain their own locations for PowerShell modules, so when you add new modules (i.e. via Install-Module), you need to do this for both PowerShell versions separately.

There is one folder path though that is shared by both Windows PowerShell and PowerShell 7: although introduced by Windows PowerShell, PowerShell 7 also looks into this folder and automatically loads modules located there:

C:\Program Files\WindowsPowerShell\Modules

To use modules in both PowerShell versions, make sure you copy the module to this folder. When using Install-Module, use -Scope AllUsers (or omit the parameter altogether).

Since the folder affects all users, it is protected, and you need Administrator privileges to add modules to it.

Note that there is another path where PowerShell looks for modules:

C:\Windows\system32\WindowsPowerShell\v1.0\Modules

This is where all Microsoft modules reside. This path, too, is shared by PowerShell 7.




You are a PowerShell Professional, passionate about improving your code and skills? You take security seriously and are always looking for the latest advice and guidance to make your code more secure and faster? You’d love to connect to the vibrant PowerShell community and get in touch with other PowerShell Professionals to share tricks and experience? Then PowerShell Conference EU 2020 might be just the right place for you: https://psconf.eu (June 2-5, 2020 in Hanover, Germany).

It’s a unique mixture of classic conference with three parallel tracks filled with fast-paced PowerShell presentations, and advanced learning class with live discussions, Q&A and plenty of networking.

Secure your seat while they last: https://psconf.eu/register.html.

Twitter This Tip! ReTweet this Tip!

Anonymous
  • Best practice: do not add an code to the "C:\Windows\System32\WindowsPowerShell\v1.0\Modules" path. Leave this to the Microsoft software team. Put/install custom Modules in the user's path or in the AllUsers location.