Skip to content

Get-ChieldItem fails with "Cannot find a provider ..." on version 6.2.1 #9840

@atanasa

Description

@atanasa

I have a module that loads a nested binary module (due to support for desktop and core editions). The binary module defines a provider that has a default PSDrive.
When calling Get-ChieldItem <qualified path> it fails with "Cannot find a provider with the name '...'". This has changed since 6.0 when it used to work.

I have created a sample repro module:

ReproProviderNameMismatch.zip

Summary:

  • The module must be nested to get this to reproduce
  • The provider must do something at initialization time that triggers a capture of the Provider.FullName (or something like that). In my case this is the PSDriveInfo constructor probably:
      protected override Collection<PSDriveInfo> InitializeDefaultDrives() {
         var drive = new PSDriveInfo(
            "defaultSampleDrive",
            ProviderInfo,
            "/",
            "Sample default drive",
            null);
         var result = new Collection<PSDriveInfo> {drive};
         return result;
      }

If the InitializeDefaultDrives in the sample is removed, then the issue would not be reproduced.

Steps to reproduce

  1. Build the sample module with dotnet build
  2. Load the module from the build output and run the following:
import-module "...ReproModule.psd1"

New-PSDrive -Name "prv1" -Root "/" -PSProvider "SamplePrv"

$item = get-item "prv1:\test.txt"
$item | fl *

Get-ChildItem $item.PSPath
  1. Observe the PSPath value

Expected behavior

The command to return the item like this:

PSPath                          PSProvider            PSIsContainer Name
------                          ----------            ------------- ----
ReproModule\SamplePrv::test.txt ReproModule\SamplePrv         False test.txt

Probably the PSPath value should be:

PSPath        : ReproModule\SamplePrv::test.txt

Actual behavior

PSPath value is:

PSPath        : module\SamplePrv::test.txt

The command fails with:

Get-ChildItem : Cannot find a provider with the name 'module\SamplePrv'.
At line:1 char:1
+ Get-ChildItem $item.PSPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (module\SamplePrv:String) [Get-ChildItem], ProviderNotFoundException
+ FullyQualifiedErrorId : ProviderNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.1
PSEdition                      Core
GitCommitId                    6.2.1
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalityResolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions