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 ';'
Suggest adding a new command with a mandatory parameter
FromTarget
with the typeString[]
that has a validate set ofSession
,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: