Creates a junction, or updates an existing junction if its target is different.
Install-Junction [-Link] <String> [-Target] <String> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Creates a junction given by -Link which points to the path given by -Target. If Link exists, deletes it and re-creates it if it doesn't point to Target.
Both -Link and -Target parameters accept relative paths for values. Any non-rooted paths are converted to full paths using the current location, i.e. the path returned by Get-Location.
Beginning with Carbon 2.0, returns a System.IO.DirectoryInfo object for the target path, if one is created. Returns a System.IO.DirectoryInfo object for the junction, if it is created and/or updated.
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Link | String | The junction to create/update. Relative paths are converted to absolute paths using the current location. |
true | false | |
| Target | String | The target of the junction, i.e. where the junction will point to. Relative paths are converted to absolute paths using the curent location. |
true | false | |
| PassThru | SwitchParameter | Return a |
false | false | False |
| Force | SwitchParameter | Create the target directory if it does not exist. |
false | false | False |
| WhatIf | SwitchParameter | false | false | ||
| Confirm | SwitchParameter | false | false | ||
| CommonParameters | This cmdlet supports common parameters. For more information type Get-Help about_CommonParameters. |
System.IO.DirectoryInfo. To return a DirectoryInfo object for installed junction, use the PassThru switch.
Install-Junction -Link 'C:\Windows\system32Link' -Target 'C:\Windows\system32'
Creates the C:\Windows\system32Link directory, which points to C:\Windows\system32.
Install-Junction -Link C:\Projects\Foobar -Target 'C:\Foo\bar' -Force
This example demonstrates how to create the target directory if it doesn't exist. After this example runs, the directory C:\Foo\bar and junction C:\Projects\Foobar will be created.