Where do modules live?
PowerShell defines an environment variable called PSMODULEPATH
, which contains a list of folders that it checks for modules. Viewing PSMODULEPATH
is simplified by the –split
operator to split the path wherever it sees a semicolon:
Here, you can see that there are four folders where PowerShell is looking for modules in this session. For it to find our AreaFunctions
module, there needs to be a AreaFunctions
subfolder in one of these locations with our psm1
file in it.
Once we have created a folder and placed the AreaFunctions.psm1
file in it, we can import the module by name rather than by path:
Get Getting Started with PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.