Join-Path
Combines a path and a child path into a single path.
구문
Default (기본값)
Join-Path
[-Path] <String[]>
[-ChildPath] <String>
[-Resolve]
[-Credential <PSCredential>]
[-UseTransaction]
[<CommonParameters>]
Description
The Join-Path
cmdlet combines a path and child-path into a single path.
The provider supplies the path delimiters.
예제
Example 1: Combine a path with a child path
Join-Path -Path "path" -ChildPath "childpath"
path\childpath
This command uses Join-Path
to combine a path with a childpath.
Since the command is executed from the FileSystem provider, it provides the \
delimiter to
join the paths.
Example 2: Combine paths that already contain directory separators
Join-Path -Path "path\" -ChildPath "\childpath"
path\childpath
Existing directory separators \
are handled so there is only one separator between Path and
ChildPath.
Example 3: Display files and folders by joining a path with a child path
Join-Path "C:\win*" "System*" -Resolve
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.
Example 4: Use Join-Path with the PowerShell Registry provider
PS HKLM:\> Join-Path -Path System -ChildPath *ControlSet* -Resolve
HKLM:\System\ControlSet001
HKLM:\System\CurrentControlSet
This command displays the registry keys in the HKLM\System
registry subkey that include
ControlSet
.
The Resolve parameter, attempts to resolve the joined path, including wildcards from the current
provider path HKLM:\
Example 5: Combine multiple path roots with a child path
Join-Path -Path C:, D:, E:, F: -ChildPath New
C:\New
D:\New
E:\New
F:\New
This command uses Join-Path
to combine multiple path roots with a child path.
Note
The Drives specified by Path must exist or the join of that entry will fail.
Example 6: Combine the roots of a file system drive with a child path
Get-PSDrive -PSProvider FileSystem |
ForEach-Object {$_.Root} |
Join-Path -ChildPath "Subdir"
C:\Subdir
D:\Subdir
This command combines the roots of each PowerShell file system drive in the console with the
Subdir
child path.
The command uses the Get-PSDrive
cmdlet to get the PowerShell drives supported by the FileSystem
provider. The ForEach-Object
statement selects only the Root property of the PSDriveInfo
objects and combines it with the specified child path.
The output shows that the PowerShell drives on the computer included a drive mapped to the
C:\Program Files
directory.
매개 변수
-ChildPath
Specifies the elements to append to the value of the Path
parameter. Wildcards are permitted. The
ChildPath
parameter is required, although the parameter name ("ChildPath") is optional.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | 1 |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Credential
Note
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.
매개 변수 속성
형식: | PSCredential |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Path
Specifies the main path (or paths) to which the child-path is appended. The value of Path determines which provider joins the paths and adds the path delimiters. Wildcards are permitted.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
별칭: | PSPath |
매개 변수 집합
(All)
Position: | 0 |
필수: | True |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Resolve
Indicates that this cmdlet should attempt to resolve the joined path from the current provider.
- If you use wildcards, the cmdlet returns all paths that match the joined path.
- If you don't use wildcards, the cmdlet returns an error if the path doesn't exist.
매개 변수 속성
형식: | SwitchParameter |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-UseTransaction
Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | usetx |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
입력
String
You can pipe a string that contains a path to this cmdlet.
출력
String
This cmdlet returns a string that contains the resulting path.
참고
The cmdlets that contain the Path noun manipulate path names and return the names in a concise
format that all PowerShell providers can interpret. They're designed to be used where you want to
display all or part of a path 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.
This 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.