Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-PSModulePath: Fails with unclear exception when user is SYSTEM and Scope is CurrentUser #122

Open
johlju opened this issue Feb 18, 2024 · 0 comments
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.

Comments

@johlju
Copy link
Member

johlju commented Feb 18, 2024

Problem description

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

Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module version used

0.17.0
@johlju johlju added bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community. labels Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

1 participant