PSDriveInfo is null for Get-Item -Path <provider qualified path>
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I’m implementing a custom cmdlet provider and stumbled upon an issue with provider qualified path:
- When getting an item with a rooted path like
drive:/path/to/item
the provider instance has assigned a PSDriveInfo instance on invocation by the base provider. - When getting an item with a provider qualified path:
provider\qualified::drive:/path/to/item
the provider is invoked without having a PSDriveInfo instance assigned.
Within the provider I can compensate by parsing the drive name from the path and fetch the drive info from the session state: SessionState.Drive.Get("drive")
.
Also this changes the returned item which can be observed by the user:
Get-item C:\ | fl *
shows a PSDrive property.- 'Get-item “Microsoft.PowerShell.Core\FileSystem::c:\ | fl *” doesn’t show a PSDrive property.
I’ve debugged this with the code base for v7.2.6 and it look to me that LocationGlobber.GetProviderPath(..)
should return the drive info in this case as well or should be called a second time with the provider name removed from the paths maybe?
Expected behavior
PS> (get-item "Microsoft.PowerShell.Core\FileSystem::c:\").PSDrive -eq $null
False
Actual behavior
PS> (get-item "Microsoft.PowerShell.Core\FileSystem::c:\").PsDrive -eq $null
True
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
AccessDBProviderSample06 - PowerShell
This sample shows how to overwrite content methods to support calls to the Clear-Content , Get-Content , and Set-Content cmdlets. These methods ...
Read more >Powershell Provider - GetItem Path Error - Custom File as ...
I am trying to create my custom Powershell Provider that is derived from NavigationCmdletProvider. I have overridden PSDriveInfo to read and ...
Read more >Exchange 2016 CU6 craches
Guys,After trying to update the Exchange 2016 to CU6 its keep craching everytime.the below error is and hope someone can ad.
Read more >Exchange 2013 CU16 and CU17 failed cannot find path \ ...
Like this one, it states that it cannot find the path to the folder "grammars" ... PSDriveInfo drive, ContainerCmdletProvider provider, S.
Read more >Professional Windows PowerShell Programming: Snapins, ...
Snapins, Cmdlets, Hosts and Providers Arul Kumaravel. the path values passed to ItemExists() may be fully qualified or drive qualified.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I see, thank you!
This is definitely a departure from basic PowerShell concepts. Fixing this was declined in #5785.