且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找出文件是否是PowerShell中的符号链接

更新时间:2023-11-25 16:29:52

尝试一下:

function Test-ReparsePoint([string]$path) {
  $file = Get-Item $path -Force -ea SilentlyContinue
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}

这是一个非常小的实现,但是应该可以解决.请注意,这不能区分硬链接和符号链接.在下面,它们都只是利用 NTFS重新解析点

It is a pretty minimal implementation, but it should do the trick. Note that this doesn't distinguish between a hard link and a symbolic link. Underneath, they both just take advantage of NTFS reparse points, IIRC.