Permanently remove UNC path from $env:PSModulePath: PowerShell

Issue: Powershell Attempts to Load Modules from UNC Path

When users at my workplace have their folders redirected to a UNC path, this affects the performance of my PowerShell. Every time I start up PowerShell, it takes a long time to load modules from the UNC path. This also affects how I use cmdlets because it tries to search the UNC path for cmdlet context.


This command shows the UNC directory, however it doesn’t show up in System’s Environment Variables dialog editor.


I want to get rid of the UNC directory so that PowerShell doesn’t keep looking for module support from the UNC directory.

Editing an existing session’s $env:PSModulePath would be a temporary fix, but I need a permanent solution.

To permanently remove the UNC path from PowerShell’s module path, follow these steps:

  1. Open the “System Properties” dialog by right-clicking “This PC” and selecting “Properties”.
  2. Click on “Advanced system settings” on the left sidebar.
  3. Click on the “Environment Variables” button at the bottom of the “Advanced” tab.
  4. Under “System Variables”, find the “PSModulePath” variable and click “Edit”.
  5. Remove the UNC path from the list of paths, making sure to separate each path with a semicolon (;).
  6. Click “OK” to close all windows.

Note that this change will affect all users on the computer, not just the current user. If you only want to remove the UNC path for the current user, edit the “PSModulePath” variable under “User Variables” instead.