79591296

Date: 2025-04-24 19:01:10
Score: 1
Natty:
Report link

As it turns out I was misinformed and the premise of the question is erroneous.

As @mklement0 points out in the OP comments, New-PSDrive -Scope Local (the default) does in fact create a drive in the scope of the module, which is not accessible to the module's calling scope (without using -Scope Global).

In my case, my custom module created a PSDrive in the local scope only if it doesn't already exist, but the code immeditately before it imported a module (the ConfigurationManager module), which created the same PSDrive in the Global scope during its import process, so I was under the mistaken impression that my locally scoped PSDrive was somehow being made available outside of the custom module's scope.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @mklement0
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: mmseng