PowerShell Join-Path Cmdlet
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed Split-Path cmdlet in PowerShell.
https://cloudaffaire.com/powershell-split-path-cmdlet/
In this blog post, we will discuss Join-Path cmdlet in PowerShell. You can use Join-Path cmdlet to combine a parent path and a child path. For example, suppose you have a file that you want to create some directory in all the drive, you can use the drive letter as parent path and your directory as a child path and combine them to get the paths necessary to create the directory in all drive. Join-Path can be used to create an absolute path for your files, directories, or registry keys.
Join-Path Cmdlet Syntax:
1 2 3 4 5 6 7 |
## Join-Path ## [-Path] ## [-ChildPath] ## [-Resolve] ## [-Credential ## [-UseTransaction] ## [ |
Join-Path Cmdlet Argument List:
- –Credential: To impersonate another user or elevate your credentials
- –ChildPath: Specifies the elements to append to the value of the Path parameter. Wildcards are permitted.
- –Path: Specifies the main path (or paths) to which the child-path is appended. Wildcards are permitted.
- –Resolve: Indicates that this cmdlet should attempt to resolve the joined path from the current provider.
- –UseTransaction: Includes the command in the active transaction. This parameter is valid only when a transaction is in progress.
PowerShell Join-Path Cmdlet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
##################################### ## PowerShell | Cmdlet | Join-Path ## ##################################### ## PowerShell Latest Version (5) ## combine a parent path and a child path in PowerShell Join-Path -Path "C:\" -ChildPath "Dir1\Dir2\File1.txt" Join-Path -Path "C:\Dir1" -ChildPath "Dir2\File1.txt" ## combine multiple parent paths to a child path in PowerShell Join-Path -Path C:, D:, E: -ChildPath "Dir1\File1.txt" ## get all path with regular expression in PowerShell Join-Path -Path C:\Windows -ChildPath System* -Resolve ## combine parent and child registry path in PowerShell Join-Path -Path HKCU:\Software -ChildPath MyRegKey |
Hope you have enjoyed this article. In the next blog post, we will discuss Resolve-Path cmdlet in PowerShell.
To Set more details on PowerShell, kindly follow below official documentation