Closed sethvs closed 5 years ago
Hi @sethvs! That path is not included by default. Here is what I see in $env:PSModulePath
on PowerShell Core 6.0.2:
C:\Users\marke\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\6.0.2\Modules
I mean it is present in:
[System.Environment]::GetEnvironmentVariable("psmodulepath", [System.EnvironmentVariableTarget]::Machine)
C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
So when you use Add-WindowsPSModulePath function, the result is that C:\Program Files\WindowsPowerShell\Modules
is included twice:
[6.1.0-preview.3] PS C:\Folder> $env:PSModulePath -split ';'
C:\Users\User\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
[6.1.0-preview.3] PS C:\Folder> Add-WindowsPSModulePath
[6.1.0-preview.3] PS C:\Folder> $env:PSModulePath -split ';'
C:\Users\User\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\Users\User\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
Hmmm... I think it is fine to keep it in there. It doesn't hurt anything, but if someone has modified their PSModulePath env var to no no longer include that path, then it would be missing.
I guess a better way would be to paths only if they don't already exist in PSModulePath.
Since
${env:programfiles}\WindowsPowerShell\Modules
is in PSModulePath machine environment variable, it should not be added twice.