Tests if a path is a junction.
Test-PathIsJunction [-Path] <String> [<CommonParameters>]
Test-PathIsJunction -LiteralPath <String> [<CommonParameters>]
The Test-PathIsJunction function tests if path is a junction (i.e. reparse point). If the path doesn't exist, returns $false.
Carbon adds an IsJunction extension method on DirectoryInfo objects, which you can use instead e.g.
Get-ChildItem -Path $env:Temp |
Where-Object { $_.PsIsContainer -and $_.IsJunction }
would return all the junctions under the current user's temporary directory.
The LiteralPath parameter was added in Carbon 2.2.0. Use it to check paths that contain wildcard characters.
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Path | String | The path to check. Wildcards allowed. If using wildcards, returns |
true | false | |
| LiteralPath | String | The literal path to check. Use this parameter to test a path that contains wildcard characters. This parameter was added in Carbon 2.2.0. |
true | false |
Test-PathIsJunction -Path C:\I\Am\A\Junction
Returns $true.
Test-PathIsJunction -Path C:\I\Am\Not\A\Junction
Returns $false.
Get-ChildItem * | Where-Object { $_.PsIsContainer -and $_.IsJunction }
Demonstrates an alternative way of testing for junctions. Uses Carbon's IsJunction extension method on the DirectoryInfo type to check if any directories under the current directory are junctions.
Test-PathIsJunction -LiteralPath 'C:\PathWithWildcards[]'
Demonstrates how to test if a path with wildcards is a junction.