Perhaps surprisingly, using -Name decorates the strings being output with NoteProperty members from the underlying PS provider, such as .PSPath, just as with the default output types (e.g., System.IO.FileInfo / System.IO.DirectoryInfo for the filesystem provider).
However, this currently happens inconsistently, namely only if -Recurse isn't also specified.
As an aside: providing a way to opt out of this decoration (-Raw) may be helpful for performance reasons; see also: #9119
Steps to reproduce
Run the following Pester test:
Describe "Get-ChildItem -Name provider-properties test" {
It "-Name adds provider properties" {
Get-ChildItem / -Name | Select-Object -First 1 | Get-Member -Name PSPath | Should -Not -BeNullOrEmpty
}
It "-Name -Recurse adds provider properties too" {
Get-ChildItem / -Name -Recurse | Select-Object -First 1 | Get-Member -Name PSPath | Should -Not -BeNullOrEmpty
}
}
Expected behavior
Both tests should pass.
Actual behavior
Executing script ....Tests.ps1
Describing Get-ChildItem -Name provider-properties test
[+] -Name adds provider properties 612ms
[-] -Name -Recurse adds provider properties too 156ms
Expected a value, but got $null or empty.
6: Get-ChildItem / -Name -Recurse | Select-Object -First 1 | Get-Member -Name PSPath | Should -Not -BeNullOrEmpty
at <ScriptBlock>, ....Tests.ps1: line 6
Environment data
PowerShell Core 6.2.0-preview.4
Windows PowerShell v5.1.17134.407
Perhaps surprisingly, using
-Namedecorates the strings being output with NoteProperty members from the underlying PS provider, such as.PSPath, just as with the default output types (e.g.,System.IO.FileInfo/System.IO.DirectoryInfofor the filesystem provider).However, this currently happens inconsistently, namely only if
-Recurseisn't also specified.As an aside: providing a way to opt out of this decoration (
-Raw) may be helpful for performance reasons; see also: #9119Steps to reproduce
Run the following Pester test:
Expected behavior
Both tests should pass.
Actual behavior
Environment data