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: New command proposal #103

Closed
johlju opened this issue Mar 26, 2023 · 0 comments · Fixed by #104
Closed

Get-PSModulePath: New command proposal #103

johlju opened this issue Mar 26, 2023 · 0 comments · Fixed by #104
Labels
enhancement The issue is an enhancement request. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@johlju
Copy link
Member

johlju commented Mar 26, 2023

Suggest adding a new command with a mandatory parameter FromTarget with the type String[] that has a validate set of Session, User, Machine. The command returns the concatenated paths (separated with semi-colon) depending on what targets was passed to the parameter. Multiple targets should be able to be passed.

This command should be used by Set-PSModulePath as suggested in issue #102.

The code suggestion:

            <#
                Get the environment variables from all targets session, user and machine.
                Casts the value to System.String to convert $null values to empty string.
            #>
            $modulePathSession = [System.String] [System.Environment]::GetEnvironmentVariable('PSModulePath')
            $modulePathUser = [System.String] [System.Environment]::GetEnvironmentVariable('PSModulePath', 'User')
            $modulePathMachine = [System.String] [System.Environment]::GetEnvironmentVariable('PSModulePath', 'Machine')

            $modulePath = $modulePathSession, $modulePathUser, $modulePathMachine -join ';'

            $modulePathArray = $modulePath -split ';' |
                Where-Object -FilterScript {
                    -not [System.String]::IsNullOrEmpty($_)
                } |
                Sort-Object -Unique

            $modulePath = $modulePathArray -join ';'
@johlju johlju added enhancement The issue is an enhancement request. 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 Mar 26, 2023
@johlju johlju added in progress The issue is being actively worked on by someone. and removed help wanted The issue is up for grabs for anyone in the community. labels Mar 26, 2023
@johlju johlju removed the in progress The issue is being actively worked on by someone. label Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant