When the command Get-PSModulePath is called as the user SYSTEM with the parameter Scope set to CurrentUser then if fails with an unclear exception.
Verbose logs
PS> whoami
nt authority\system
PS> import-module .\output\RequiredModules\DscResource.Common
PS> Get-PSModulePath -Scope CurrentUser
Join-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\source\..\output\RequiredModules\DscResource.Common\0.17.1\DscResource.Common.psm1:3221
char:41
+ Join-Path -Path $documentsFolder -ChildPath ' ...
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Join
PathCommand
PS> Get-PSModulePath -Scope AllUsers
C:\Program Files\WindowsPowerShell\Modules
How to reproduce
Run the command Get-PSModulePath -Scope CurrentUser as SYSTEM.
Expected behavior
Should return an error message that is more clear what is going on.
Current behavior
Fails with an unclear message.
Suggested solution
Should throw a clear message saying that the path retrieved was $null and possible output the current user in the error message ($env:USERNAME on WIndows and $env:USER on Linux and macOS). 🤔
Operating system the target node is running
OsName : Microsoft Windows 11 Business
OsOperatingSystemSKU : 48
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage : en-US
OsMuiLanguages : {en-US, en-GB}
PowerShell version and build the target node is running
Problem description
When the command
Get-PSModulePath
is called as the user SYSTEM with the parameterScope
set toCurrentUser
then if fails with an unclear exception.Verbose logs
How to reproduce
Run the command
Get-PSModulePath -Scope CurrentUser
as SYSTEM.Expected behavior
Should return an error message that is more clear what is going on.
Current behavior
Fails with an unclear message.
Suggested solution
Should throw a clear message saying that the path retrieved was
$null
and possible output the current user in the error message ($env:USERNAME
on WIndows and$env:USER
on Linux and macOS). 🤔Operating system the target node is running
PowerShell version and build the target node is running
Module version used