$Env:PSModulePath issue

David M. Gray - Admin 1 Reputation point
2021-04-09T11:40:47.087+00:00

Hello
Quite new to PowerShell on Windows 10 and I'm finding an issue with PSModulePath being set to a network share which I do not want as it takes
an age to load. Strangely the speed issue only manifests itself when I run PS commands in Visual Studio code (preferred option) but not in ISE.

I have tried the following to re-order the search list but it only persists for that session.

$Env:PSModulePath = "C:\Program Files\WindowsPowerShell\Modules;\domain.com\fileshare\redirected$\first.last\Documents\WindowsPowerShell\Modules;C:\Program Files (x86)\Red Gate\SQL Change Automation PowerShell\Modules\;C:\Program Files (x86)\Microsoft Azure Information Protection\Powershell"

But it is not persisted.

My $PROFILE looks like this.

86190-psprofile.png

I know I need to read up on PS profiles but wanted to get this path stuff sorted first.

Thanks in advanced.

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2021-04-09T12:21:32.887+00:00

    Hi,

    The value of $env:PSModulePath is constructed each time PowerShell starts. What does your $PSVersionTable look like?
    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.