Split-Path -LiteralPath $PSHOME -Leaf
The cmdlet should return the name of the filesystem element furthest down the directory tree (the leaf).
Split-Path : Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
At line:1 char:1
+ Split-Path -LiteralPath $PSHOME -Leaf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Split-Path], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.SplitPathCommand
Name Value
---- -----
PSVersion 7.1.0-preview.5
PSEdition Core
GitCommitId 7.1.0-preview.5
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
It works with -Path "path/here/" -Leaf so I think it should work with -LiteralPath as well.
Hmm, yeah, something's definitely up with those parameter sets:
PS C:\Users\joelp> gcm split-path -syn
Split-Path [-Path] <string[]> [-Parent] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-Leaf] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-LeafBase] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-Extension] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-Qualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-NoQualifier] [-Resolve] [-Credential <pscredential>] [<CommonParameters>]
Split-Path [-Path] <string[]> [-Resolve] [-IsAbsolute] [-Credential <pscredential>] [<CommonParameters>]
Split-Path -LiteralPath <string[]> [-Resolve] [-Credential <pscredential>] [<CommonParameters>]e
-LiteralPath should be listed for each set, and -Parent, -Leaf, and -LeafBase should be in both sets, but it seems there's only one set for -LiteralPath at the moment.
it's been by design since early days.
wondering that nobody noticed.
Had a quick look, and already found something I'm very confused by -- why is IsAbsolute on Split-Path? O.o
Seems like that's way more useful on Test-Path. What on earth is going on in that cmdlet... I'd want to excise that parameter and move it to Test-Path, and then fix the parameter set issues. One thing at a time, I suppose...
Good catch, @jantari, but note that your issue is a duplicate of #8751
You're right, I used search beforehand but it let me down. Thanks.