Combine a path and one or more child-paths into a single path.

      Join-Path [-path] string[] [-childPath] string [-resolve]
          [-credential PSCredential] [-UseTransaction] [CommonParameters]

   -Path string[]
       The main path (or paths) to which the child-path is appended.
       Wildcards are permitted. {may be piped}

   -childPath string
       The elements to append to the value of Path.
       Wildcards are permitted. {may be piped}

       Display the items that are referenced by the joined path.

   -credential PSCredential
       Use a credential to validate access to the file. Credential represents
       a user-name, such as "User01" or "Domain01\User01", or a PSCredential
       object, such as the one retrieved by using the Get-Credential cmdlet.
       If you type a user name, you will be prompted for a password.
       This parameter is not supported by any PowerShell core cmdlets or providers.

       Include the command in the active transaction.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

The appropriate path delimiters will be supplied by the provider.
In PowerShell 6.0 and above, join-path can combine an indefinite number of child paths.


Join two paths:

PS C:\> join-path -path c:\win* -childpath system*

The above will resolve to: C:\windows\System

Join 2 paths and display the files and folders, -resolve will display the full pathname:

PS C:\> join-path -path c:\win* system* -resolve

Display the registry keys in the HKLM\System hive that include "ControlSet":

PS C:\> set-location HKLM:
PS HKLM:\> join-path System *ControlSet* -resolve

#Here come old flattop, he come grooving up slowly, He got joo-joo eyeball, he one holy roller# ~ The Beatles (Come Together)

Related PowerShell Cmdlets:

convert-path - Convert a ps path to a provider path.
resolve-path - Resolves the wildcards in a path.
split-path - Return part of a path.
test-path - Return true if the path exists, otherwise return false.
get-help about_namespace

Copyright © 1999-2020
Some rights reserved