We have a few modules residing on an SMB file share. We want to extend the module path where PowerShell looks for scripts (temporarily, not permanently).
By default, the contents of $env:PSModulePath environment variable is this:
> $env:PSModulePath -split ';'
C:\Users\xxx\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\windows\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
As documented by Microsoft, I wanted to extend this environment variable by one or more locations, so that calling the Import-Module or even a #Required header would work.
Thus, I executed the following commands:
$customModulePaths = @('\\myServer\myShare\subfolder\module1\',
'\\myServer\myShare\subfolder\module2\')
$env:PSModulePath = $env:PSModulePath + [System.IO.Path]::PathSeparator + $($customModulePaths -join [System.IO.Path]::PathSeparator)
The scripts themselves are:
\\myServer\myShare\subfolder\module1\module1.psm1\\myServer\myShare\subfolder\module2\module2.psm1
The module name is the same as the parent folder, and they have a manifest file (.psd1).
I verified that the environment variable was indeed modified by checking the first command again.
Next, I executed Get-Module -ListAvailable -Refresh, expecting to see the 2 modules appear. However, the command's output only references items located in the original $env:PSModulePath's folders. Executing Import-Module module1 also results in an error, stating that the module can't be found.
Am I missing something or is what I'm trying to do not possible? Or is it due to the fact that I'm using UNC instead of local paths?
\\myServer\myShare\subfolder\module1\module1.psd1)?New-ModuleManifest.Import-Module \\myServer\myShare\subfolder\module1andImport-Module \\myServer\myShare\subfolder\module2?\\myServer\myShare\subfolder, not the individual module folders