$ env: PSModulePath vs.% PSModulePath%

How is it that cmd.exe shows different values ​​for PSModulePath

than PowerShell?

PowerShell:

\\share\user\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

      

CMD:

C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

      

enter image description here

+3


source to share


2 answers


Environment variables seem to change "locally" at runtime (changes are not saved to the system). Running cmd from the PowerShell console should work as you expect:



PS>cmd /c echo %psmodulepath%

      

+2


source


Anytime you start PowerShell, it will create a set of environment variables for that session. They can all be found under $ env (for example, $ env: PSModulePath). There is a set of defaults that go here. These defaults are hard-coded, but you can of course change these defaults by changing them in one of the script profiles.

As far as CMD.exe is concerned, whenever it is run it creates environment variables as well, however the environment variables are pulled from the OS environment.



Go to Control Panel -> System -> Advanced Options -> Advanced Tab -> Environment Variables

0


source







All Articles