Created
March 14, 2024 19:03
-
-
Save pmolodo/a48c1bbc96d7e2723b5ae2ffcdf29c1d to your computer and use it in GitHub Desktop.
Test presence of ReparsePoint file attribute on junctions, and children of junctions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version 1.0 | |
$THIS_FILE = [System.IO.FileInfo]$MyInvocation.MyCommand.Path | |
$THIS_DIR = $THIS_FILE.Directory | |
Write-Host $THIS_DIR | |
$TEST_ROOT = "${THIS_DIR}\test_root" | |
$SYMLINK_PARENT = "${TEST_ROOT}\c\path\to" | |
$SYMLINK = "${SYMLINK_PARENT}\some" | |
$SYMLINK_TARGET = "${TEST_ROOT}\d\another\location" | |
$TO_RESOLVE_DIR_NAME = "directory" | |
$TO_RESOLVE_SYMLINK = "${SYMLINK}\${TO_RESOLVE_DIR_NAME}" | |
$TO_RESOLVE_REAL = "${SYMLINK_TARGET}\${TO_RESOLVE_DIR_NAME}" | |
New-Item -ItemType Directory $TO_RESOLVE_REAL | |
New-Item -ItemType Directory $SYMLINK_PARENT | |
New-Item -ItemType Junction -Path $SYMLINK -Target $SYMLINK_TARGET | |
function Write-FileAttrs { | |
param( | |
[string]$path | |
) | |
Write-Host $path | |
Write-Host " : " (Get-Item $path).Attributes | |
} | |
# The link to the exact symlink has the ReparsePoint attr.. | |
Write-FileAttrs $SYMLINK | |
# ...but a child doesn't | |
Write-FileAttrs $TO_RESOLVE_SYMLINK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment