-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalitythe issue is for cleaning up the code with no impact on functionalityResolution-FixedThe issue is fixed.The issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Description
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:
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
- Build the sample module with
dotnet build - 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- 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
Labels
Issue-Code Cleanupthe issue is for cleaning up the code with no impact on functionalitythe issue is for cleaning up the code with no impact on functionalityResolution-FixedThe issue is fixed.The issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.