CmdID / PowerShell / Cmdlets / Split
Split-Path
Returns the specified part of a path. PowerShell reference
From the PowerShell reference 10 parameters
What it does
Returns the specified part of a path. The Split-Path cmdlet returns only the specified part of a path, such as the parent folder, a subfolder, or a filename. It can also get items that are referenced by the split path and tell whether the path is relative or absolute. You can use this cmdlet to get or submit only a selected part of a path.
Split-Path [-Path] <String[]> [-Parent] [-Resolve] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]Split-Path [-Path] <String[]> [-NoQualifier] [-Resolve] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]Split-Path [-Path] <String[]> [-Leaf] [-Resolve] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]Split-Path [-Path] <String[]> [-Qualifier] [-Resolve] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]Split-Path [-Path] <String[]> [-Resolve] [-IsAbsolute] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]Split-Path -LiteralPath <String[]> [-Resolve] [-Credential <PSCredential>] [-UseTransaction] [<CommonParameters>]
Get the qualifier of a path
Split-Path -Path "HKCU:\Software\Microsoft" -QualifierIdentifyDisplay filename portion of the path
Split-Path -Path .\folder1\*.txt -LeafIdentifyGet the parent container
Split-Path -Path .\folder1\file1.txt -ParentIdentifyDetermines whether a path is absolute
Split-Path -Path ".\My Pictures\*.jpg" -IsAbsoluteIdentifyChange location to a specified path
PS C:> Set-Location (Split-Path -Path $PROFILE)
PS C:\Users\User01\Documents\PowerShell>IdentifySplit a path using the pipeline
'C:\Users\User01\My Documents\My Pictures' | Split-PathIdentifyIts page in the reference: Split-Path.
Parameters
-CredentialNOTE: This parameter isn't supported by any providers installed with PowerShell. To impersonate another user, or elevate your credentials when running this cmdlet, use Invoke-Command.-IsAbsoluteIndicates that this cmdlet returns $true if the path is absolute and $false if it's relative. On Windows, an absolute path string must start with a provider drive specifier, like C: or HKCU:. A relative path starts with a dot (.) or a dot-dot (..).-LeafWhen using the Leaf parameter, Split-Path returns only the last item in the path string supplied, regardless whether that item is a file or a directory.-LiteralPathSpecifies the paths to be split. Unlike Path, the value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcard characters. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.-NoQualifierIndicates that this cmdlet returns the path without the qualifier. For the FileSystem or registry providers, the qualifier is the drive of the provider path, such as C: or HKCU:. For example, in the path C:\Test\Logs\Pass1.log, it returns only \Test\Logs\Pass1.log.-ParentSplit-Path returns only the parent container portion of the path string supplied. If the Path string doesn't contain a parent container, Split-Path returns an empty string.-PathSpecifies the paths to be split. Wildcard characters are permitted. If the path includes spaces, enclose it in quotation marks. You can also pipe a path to this cmdlet.-QualifierIndicates that this cmdlet returns only the qualifier of the specified path. For the FileSystem or Registry providers, the qualifier is the drive of the provider path, such as C: or HKCU:.-ResolveIndicates that this cmdlet displays the items that are referenced by the resulting split path instead of displaying the path elements.-UseTransactionIncludes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.