I've played around with a lot of other Get-xxxxxx cmdlets and Get-ChildItem seems to be the only one having a different result between the two PowerShell versions.
param(
[ArgumentCompleter( {
Get-ChildItem
})]
$Object
)
Formerly returned the file/folder name.
Now returns the full path.
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This is due to FileSystemInfo.ToString changing in .NET itself. This issue was discussed in #7132 and it was ultimately decided by the PowerShell committee to maintain this behavior in #7132 (comment):
The work involved to maintain compatibility is not worth the effort as the underlying platform has introduced a change to fix an inconsistency problem. This results in a breaking change for some PowerShell users, but detecting of this will be quick and using
.FullNameor.Nameas appropriate is the right thing to do. We could make a change inJoin-Pathto support joining two absolute paths to make this simpler for scripts, but that would be a separate issue.
Generally speaking it's best to avoid depending on stringification anyway. Instead, use the property that explicitly holds the string you're looking for:
param(
[ArgumentCompleter( {
(Get-ChildItem).Name
})]
$Object
)
Thanks for the explanation :)
Most helpful comment
This is due to
FileSystemInfo.ToStringchanging in .NET itself. This issue was discussed in #7132 and it was ultimately decided by the PowerShell committee to maintain this behavior in #7132 (comment):Generally speaking it's best to avoid depending on stringification anyway. Instead, use the property that explicitly holds the string you're looking for: