It appears that env:PSModulePath is being prepended with [environment]::getfolderpath("mydocuments")\WindowsPowershell\Modules rather than $Home\Documents\WindowsPowershell\Modules as described in the docs
Redirect your mydocuments to a different folder
Start powershell and get the $env:psmodulepath
$env:PSModulePath.split(";") -contains "$home\WindowsPowershell\Modules"
$env:PSModulePath.split(";") -contains "$([environment]::getfolderpath("mydocuments"))\WindowsPowershell\Modules"
What PowerShell version are you seeing this in?
All versions
Simon Sabin
All versions
The path you give in your example seems to be a Windows PowerShell path. This repository tracks issues in PowerShell 6+.
The module path is set here:
It seems that $HOME variable comes from the $env:USERPROFILE environment variable:
It's not clear whether the inconsistency is intended, but given that this behaviour is longstanding and likely unable to be changed, we might want to move this issue to the docs repo.
I think it is Docs issue.
Its a fairly broad reaching docs problem. I'll raise a docs issue.
@joeyaiello or @sdwheeler can you transfer this issue to the docs repo?
I鈥檝e already created an issue on the docs side. You can close this one
Simon Sabin
As an aside, regarding ships that have sailed: The more appropriate definition of $HOME would be "${env:HOMEDRIVE}${env:HOMEPATH}" rather $env:USERPROFILE - while the two values are _by default_ identical, they can differ, and the former is then the better location for modules.
Therefore, basing the personal module path on [environment]::getfolderpath("mydocuments") is actually more appropriate than basing it on $HOME.
I agree that its appropriate use, its just confusing that its not documented.
Furthermore the rules for how its set if the user environment variable is set isn't clear in the docs