Powershell module is slowing down my computer.

Hi Everyone,

Based on my understanding:
PowerShell uses $Env:PSModulePath to indicate where it should look for modules to execute commands.
It does lookups on every folder in the list whenever trying to autocomplete a command with the Tab key on the command line.

Findings:
By default one of the paths in this variable is “~\My Documents\WindowsPowerShell\Modules”. This normally would be okay,
however on our domain, this directory is mounted on a file share.

PS C:\WINDOWS\system32> $ENV:PSModulePath -split ';'                                                                    
\\PRODFS01-VM\HOMEDIR$\System.Admin\My Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

The issue is that with it doing lookups in the network drive all the time it makes using PowerShell a lot less responsive, with delays of 200ms to 2000ms+ per attempted to autocomplete (which adds up over time).

Interestingly this path doesn’t appear in my local system environment variables page either like the two lines below only:

%ProgramFiles%\WindowsPowerShell\Modules
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules

Questions:

  1. Is it possible that there is some form of Group Policy which is influencing this?
  2. The latency on the Network drive causes problems with general computer responsiveness in a number of use-cases, So how can I fix this performance slowdown issue?
Note:
PS C:\WINDOWS\system32> $PSVersionTable
Name                           Value                                                                                    
----                           -----                                                                                    
PSVersion                      5.1.18362.752                                                                            
PSEdition                      Desktop                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Yeah, looks like that path is causing the slowness. Are you using any profile script ?

Check the $Profile script is being used and if it has any code to add that location in module path.