Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions reference/5.1/Microsoft.PowerShell.Management/Join-Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 02/26/2024
ms.date: 03/25/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/join-path?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Join-Path
Expand All @@ -15,8 +15,8 @@ Combines a path and a child path into a single path.
## SYNTAX

```
Join-Path [-Path] <String[]> [-ChildPath] <String> [-Resolve] [-Credential <PSCredential>] [-UseTransaction]
[<CommonParameters>]
Join-Path [-Path] <String[]> [-ChildPath] <String> [-Resolve] [-Credential <PSCredential>]
[-UseTransaction] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -29,7 +29,7 @@ The provider supplies the path delimiters.
### Example 1: Combine a path with a child path

```powershell
PS C:\> Join-Path -Path "path" -ChildPath "childpath"
Join-Path -Path "path" -ChildPath "childpath"
```

```output
Expand All @@ -38,21 +38,21 @@ 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.
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

```powershell
PS C:\> Join-Path -Path "path\" -ChildPath "\childpath"
Join-Path -Path "path\" -ChildPath "\childpath"
```

```output
path\childpath
```

Existing directory separators `\` are handled so there is only one separator between `Path` and
`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

Expand All @@ -62,8 +62,8 @@ 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.
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

Expand All @@ -79,7 +79,7 @@ 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
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
Expand All @@ -98,21 +98,23 @@ 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.
> 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

```powershell
Get-PSDrive -PSProvider FileSystem | ForEach-Object {$_.Root} | Join-Path -ChildPath "Subdir"
Get-PSDrive -PSProvider FileSystem |
ForEach-Object {$_.Root} |
Join-Path -ChildPath "Subdir"
```

```output
C:\Subdir
D:\Subdir
```

This command combines the roots of each PowerShell file system drive in the console with the `Subdir`
child path.
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**
Expand Down Expand Up @@ -143,9 +145,9 @@ Accept wildcard characters: True
### -Credential

> [!NOTE]
> This parameter is not supported by any providers installed with PowerShell.
> To impersonate another user, or elevate your credentials when running this cmdlet,
> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md).
> 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](../Microsoft.PowerShell.Core/Invoke-Command.md).

```yaml
Type: System.Management.Automation.PSCredential
Expand All @@ -161,11 +163,8 @@ Accept wildcard characters: False

### -Path

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.
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.

```yaml
Type: System.String[]
Expand All @@ -183,8 +182,8 @@ Accept wildcard characters: True

Indicates that this cmdlet should attempt to resolve the joined path from the current provider.

- If wildcards are used, the cmdlet returns all paths that match the joined path.
- If **no** wildcards are used, the cmdlet will error if the path does not exist.
- 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.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand Down Expand Up @@ -237,10 +236,10 @@ This cmdlet 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 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.
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.
Expand Down
72 changes: 34 additions & 38 deletions reference/7.4/Microsoft.PowerShell.Management/Join-Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 02/26/2024
ms.date: 03/25/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/join-path?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Join-Path
Expand All @@ -29,7 +29,7 @@ The provider supplies the path delimiters.
### Example 1: Combine a path with a child path

```powershell
PS C:\> Join-Path -Path "path" -ChildPath "childpath"
Join-Path -Path "path" -ChildPath "childpath"
```

```output
Expand All @@ -38,21 +38,21 @@ 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.
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

```powershell
PS C:\> Join-Path -Path "path\" -ChildPath "\childpath"
Join-Path -Path "path\" -ChildPath "\childpath"
```

```output
path\childpath
```

Existing directory separators `\` are handled so there is only one separator between `Path` and
`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

Expand All @@ -62,8 +62,8 @@ 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.
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

Expand All @@ -79,7 +79,7 @@ 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
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
Expand All @@ -98,21 +98,23 @@ 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.
> 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

```powershell
Get-PSDrive -PSProvider FileSystem | ForEach-Object {$_.Root} | Join-Path -ChildPath "Subdir"
Get-PSDrive -PSProvider FileSystem |
ForEach-Object {$_.Root} |
Join-Path -ChildPath "Subdir"
```

```output
C:\Subdir
D:\Subdir
```

This command combines the roots of each PowerShell file system drive in the console with the `Subdir`
child path.
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**
Expand All @@ -131,20 +133,18 @@ Join-Path a b c d e f g
a\b\c\d\e\f\g
```

The `AdditionalChildPath` parameter allows the joining of an unlimited number of paths.
The **AdditionalChildPath** parameter allows the joining of an unlimited number of paths.

In this example, no parameter names are used, thus "a" binds to `Path`, "b" to `ChildPath` and
"c-g" to `AdditionalChildPath`
In this example, no parameter names are used, thus "a" binds to **Path**, "b" to **ChildPath** and
"c-g" to **AdditionalChildPath**.

## PARAMETERS

### -AdditionalChildPath

Specifies additional elements to append to the value of the *Path* parameter. The `ChildPath`
parameter is still mandatory and must be specified as well.

This parameter is specified with the `ValueFromRemainingArguments` property which enables
joining an indefinite number of paths.
Specifies additional elements to append to the value of the **Path** parameter. The **ChildPath**
parameter is still mandatory and must be specified as well. This parameter is specified with the
`ValueFromRemainingArguments` property, which enables joining an indefinite number of paths.

This parameter was added in PowerShell 6.0.

Expand All @@ -162,8 +162,7 @@ Accept wildcard characters: False

### -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.
Specifies the elements to append to the value of the `Path` parameter. Wildcards are permitted.

```yaml
Type: System.String
Expand All @@ -180,9 +179,9 @@ Accept wildcard characters: True
### -Credential

> [!NOTE]
> This parameter is not supported by any providers installed with PowerShell.
> To impersonate another user, or elevate your credentials when running this cmdlet,
> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md).
> 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](../Microsoft.PowerShell.Core/Invoke-Command.md).

```yaml
Type: System.Management.Automation.PSCredential
Expand All @@ -198,11 +197,8 @@ Accept wildcard characters: False

### -Path

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.
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.

```yaml
Type: System.String[]
Expand All @@ -220,8 +216,8 @@ Accept wildcard characters: True

Indicates that this cmdlet should attempt to resolve the joined path from the current provider.

- If wildcards are used, the cmdlet returns all paths that match the joined path.
- If **no** wildcards are used, the cmdlet will error if the path does not exist.
- 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.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand Down Expand Up @@ -256,10 +252,10 @@ This cmdlet 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 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.
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.
Expand Down
Loading