Reputation: 4866
This is with respect to this question which I had asked earlier - Powershell: Installing Modules on Target System
Cannot find path 'C:\Users\angshuman\Documents\WindowsPowerShell\Modules\MyPSModules\MyPsModules.psd1' because it does not exist.
I am executing the same code via C# on a Windows 7 64-bit OS
_ps = PowerShell.Create();
_ps.AddScript("Import-Module MyPSModules -PassThru");
Collection<PSObject> psObjects = _ps.Invoke();
Upvotes: 17
Views: 50949
Reputation: 18166
$env:psmodulePath
is the automatic variable which holds the path used to discover modules. If it's not set, PowerShell looks in c:\windows\system32\WindowsPowerShell\v1.0\modules
and MyDocuments\WindowsPowerShell\modules
.
So it should by default always be looking in both places.
I haven't done much 32-on-64 coding, but I could see it using SysWow64 (instead of System32) if you were running a 32-bit app on a 64-bit OS.
Upvotes: 25
Reputation: 1040
And if you want to have them to have a better readability you can use this:
$env:PSModulePath.split(';')
Upvotes: 28