< Back

Test-CPathIsJunction

Sun Jan 12, 2020 11:27 pm

NAME Test-CPathIsJunction



SYNOPSIS

Tests if a path is a junction.





SYNTAX

Test-CPathIsJunction [-Path] <String> [<CommonParameters>]



Test-CPathIsJunction -LiteralPath <String> [<CommonParameters>]





DESCRIPTION

The `Test-CPathIsJunction` 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.





PARAMETERS

-Path <String>

The path to check. Wildcards allowed. If using wildcards, returns `$true` if all paths that match the wildcard

are junctions. Otherwise, return `$false`.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? 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.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Test-CPathIsJunction -Path C:\\I\\Am\\A\\Junction



Returns `$true`.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Test-CPathIsJunction -Path C:\\I\\Am\\Not\\A\\Junction



Returns `$false`.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>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.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Test-CPathIsJunction -LiteralPath 'C:\\PathWithWildcards[]'



Demonstrates how to test if a path with wildcards is a junction.











RELATED LINKS