If I remember correctly, I think the environmental variable $env:PSModulePath is a string value not an array/collection, so technically the if condition that uses -contains won't work as intended. You have to split the variable by the ';' delimiter into an array first.
$PSModulePathArray = $env:PSModulePath -split ';'
However, you're not seeing issues because the if condition is a negative match... "If ($string1
-contains $string2)" will always be false, so the negative of that will always be true, yeah?
Restart a PowerShell session multiple times and check if your custom "Business" and "Utilities" paths are in the PSModulePath variable multiple times.
We're a place where coders share, stay up-to-date and grow their careers.
If I remember correctly, I think the environmental variable $env:PSModulePath is a string value not an array/collection, so technically the if condition that uses -contains won't work as intended. You have to split the variable by the ';' delimiter into an array first.
$PSModulePathArray = $env:PSModulePath -split ';'
However, you're not seeing issues because the if condition is a negative match... "If ($string1
-contains $string2)" will always be false, so the negative of that will always be true, yeah?
Restart a PowerShell session multiple times and check if your custom "Business" and "Utilities" paths are in the PSModulePath variable multiple times.