Prerequisites
Steps to reproduce
Set your user's powershell.config.json PSModulePath
The example here is Windows-specific:
$configPath = Join-Path (Split-Path $Profile) powershell.config.json
if (Test-Path $configPath) {
$config = Get-Content $configPath | ConvertFrom-Json
$config.PSModulePath = "%LOCALAPPDATA%\powershell\Modules"
} else {
$config = @{ PSModulePath = "%LOCALAPPDATA%\powershell\Modules" }
}
$config | ConvertTo-Json | Set-Content $configPath
In a new PowerShell instance:
$Actual = cmd /c "echo %LOCALAPPDATA%\powershell\Modules"
$Api = [Management.Automation.ModuleIntrinsics]::GetPSModulePath('User')
Compare-Object $Api $Actual -IncludeEqual
Expected behavior
GetPSModulePath('User') should return the path the user has configured, so the two values should be the same.
InputObject SideIndicator
----------- -------------
S:\OneDrive - PoshCode\Documents\PowerShell\Modules ==
Actual behavior
InputObject SideIndicator
----------- -------------
C:\Users\Jaykul\AppData\Local\powershell\Modules =>
S:\OneDrive\Documents\PowerShell\Modules <=
Environment data
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.22635
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
Set your user's powershell.config.json PSModulePath
The example here is Windows-specific:
In a new PowerShell instance:
Expected behavior
GetPSModulePath('User') should return the path the user has configured, so the two values should be the same.
Actual behavior
Environment data