I’m not sure if I’m asking the right question or in the right place but here goes. I have added a new path to the PSModulePath at the machine level. I want the modules under this location to be available at any prompt for any user. However the modules at C:\FooBar are only available when the powershell session is run as admin. I have clearly missed something but I’m not sure what. I don’t know if it makes any difference but this is 2008 R2 machine running powershell v4.
# Figure out what is in the powershell module path $CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine") $CurrentValue.split(';') | sort
# Add the new path to our module path $NewPath = "C:\FooBar" [Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";$NewPath", "Machine")
# test to ensure that it has just worked – we should see our new path included [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")I had assumed that this would be the correct way to acomplish what I wanted rather than editing the alluserallhost profile in sys32.