Test in PowerShell code if a folder is a junction point?

前端 未结 6 699
梦谈多话
梦谈多话 2021-01-13 00:30

How can I test in PowerShell code if a folder is a junction point?

6条回答
  •  无人及你
    2021-01-13 01:09

    Try this:

    $TargetAttributes = (Get-Item -Path $Target -Force).Attributes.ToString()
    if ($TargetAttributes -match "ReparsePoint") {
        if ($TargetAttributes -match "Archive") {
            Write-Output ("Link to a file.")
        } else {
            Write-Output ("Link to a folder.")
        }
    } else {
        Write-Output ("Normal File or Folder.")
    }    
    

提交回复
热议问题