Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

Join-Path

Updated: October 17, 2013

Applies To: Windows PowerShell 4.0

Join-Path

Combines a path and a child path into a single path. The provider supplies the path delimiters.

Syntax

Parameter Set: Default
Join-Path [-Path] <String[]> [-ChildPath] <String> [-Credential <PSCredential> ] [-Resolve] [-UseTransaction] [ <CommonParameters>]




Detailed Description

The Join-Path cmdlet combines a path and child-path into a single path. The provider supplies the path delimiters.

Parameters

-ChildPath<String>

Specifies the elements to append to the value of Path. Wildcards are permitted. The ChildPath parameter is required, although the parameter name ("ChildPath") is optional.


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

true

-Credential<PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as "User01" or "Domain01\User01". Or, enter a PSCredential object, such as one generated by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

This parameter is not supported by any providers installed with Windows PowerShell.


Aliases

none

Required?

false

Position?

named

Default Value

Current user

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Path<String[]>

Specifies the main path (or paths) to which the child-path is appended. Wildcards are permitted.

The value of Path determines which provider joins the paths and adds the path delimiters. The Path parameter is required, although the parameter name ("Path") is optional.


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

true

-Resolve

Displays the items that are referenced by the joined path.


Aliases

none

Required?

false

Position?

named

Default Value

False

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseTransaction

Includes the command in the active transaction. This parameter can only be used when a transaction is in progress. For more information, see about_Transactions.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • System.String

    You can pipe a string that contains a path to Join-Path.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.String

    Join-Path returns a string that contains the resulting path.


Notes

  • The cmdlets that contain the Path noun (the Path cmdlets) manipulate path names and return the names in a concise format that all Windows PowerShell providers can interpret. They are designed for use in programs and scripts where you want to display all or part of a path name in a particular format. Use them like you would use Dirname, Normpath, Realpath, Join, or other path manipulators.

    You can use the path cmdlets with several providers, including the FileSystem, Registry, and Certificate providers.

    The Join-Path cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "Get-PSProvider". For more information, see about_Providers.

Examples

-------------------------- EXAMPLE 1 --------------------------

This command uses Join-Path to combine the "c:\Win*" path with the "System*" child path. The Windows PowerShell file system provider, FileSystem joins the path and adds the "\" delimiter.


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

-------------------------- EXAMPLE 2 --------------------------

This command displays the files and folders that are referenced by joining the "c:\Win*" path and the "System*" child path. It displays the same files and folders as Get-ChildItem, but it displays the fully qualified path to each item. In this command, the Path and ChildPath optional parameter names are omitted.


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

-------------------------- EXAMPLE 3 --------------------------

This command displays the registry keys in the HKLM\System registry subkey that include "ControlSet". This example shows how to use Join-Path with the Windows PowerShell registry provider.


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

-------------------------- EXAMPLE 4 --------------------------

This command uses Join-Path to combine multiple path roots with a child path.


PS C:\> join-path -path C:, D:, E:, F: -childpath New

-------------------------- EXAMPLE 5 --------------------------

This command combines the roots of each Windows PowerShell file system drive in the console with the Subdir child path.

The command uses the Get-PSDrive cmdlet to get the Windows PowerShell drives supported by the FileSystem provider. The ForEach statement selects only the Root property of the PSDriveInfo objects and combines it with the specified child path.

The output shows that the Windows PowerShell drives on the computer included a drive mapped to the C:\Program Files directory.


PS C:\> get-psdrive -psprovider filesystem | foreach {$_.root} | join-path -childpath Subdir

Related topics



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.