Bug in WMF5 with inaccessible network path in PSModulePath environment variable
In WMF5, if the PSModulePath environment variable has a UNC Path in it that is currently inaccessible, powershell fails to load many built-in modules.
For instance, if PSModulePath looks like this:
When powershell loads and times out trying to access the path, many standard cmdlets are not found; get-host, test-path, format-list, etc.
Get-member -listavailable reports back the modules, but does not list their path on disk, and many of them have no exported commands. When trying to import one of these modules powershell reports an error that the module path cannot be found.
This doesn't appear to happen with a bad local path, only with a network path.
Gregory Suvalian commented
This issue is present in ALL version of PowerShell. I reported it back in September 2015 when it was still on connect.microsoft.com (https://connect.microsoft.com/PowerShell/feedback/details/1775550/import-module-does-not-try-every-psmodulepath-directory-if-first-module-path-is-not-accessible-in-remote-session)
This broke bunch of stuff in my environment since if your UNC path is first in list then entire $PSModulePath becomes useless
Jeremy Murrah commented
Should also note that this manifests itself in DSC processing as well, as the system account cannot access the network path. Because so many basic powershell functions aren't available in that scenario most DSC resources fail in some fashion.