1 out of 2 rated this helpful - Rate this topic

PSModulePath Environment Variable

The PSModulePath environment variable stores the paths to the locations of the modules that are installed on disk. Windows PowerShell uses this variable to locate modules when the user does not specify the full path to a module. The paths in this variable are searched in the order in which they appear.

When Windows PowerShell starts, PSModulePath is created as a system environment variable with the following default value: $home\Documents\WindowsPowerShell\Modules; $pshome\Modules.

To view the PSModulePath variable

To view the paths that are specified in the PSModulePath variable, type the following command:

$env:PSModulePath

To add locations to the PSModulePath variable

To add paths to this variable, use one of the following methods:

  • To add a temporary value that is available only for the current session, run the following command at the command line:

    $env:PSModulePath = $env:PSModulePath + ";c:\ModulePath"

  • To add a persistent value that is available whenever a session is opened, add the following command to a Windows PowerShell profile:

    $env:PSModulePath = $env:PSModulePath + ";c:\ModulePath"

    For more information about profiles, see about_Profiles in the Microsoft TechNet library.

  • To add a persistent variable to the registry, create a new user environment variable called PSModulePath using the Environment Variables Editor in the System Properties dialog box.

  • To add a persistent variable by using a script, use the SetEnvironmentVariable method on the Environment class. For example, the following script adds the "C:\Program Files\Fabrikam\Module path to the value of the PSModulePath environment variable for the computer. To add the path to the user PSModulePath environment variable, set the target to "User".

    $CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
    [Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";C:\Program Files\Fabrikam\Modules", "Machine")
    
    

See Also



Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.