Find out whether a file is a symbolic link in PowerShell

后端 未结 7 498
孤城傲影
孤城傲影 2020-12-14 00:19

I am having a PowerShell script which is walking a directory tree, and sometimes I have auxiliary files hardlinked there which should not be processed. Is there an easy way

7条回答
  •  半阙折子戏
    2020-12-14 01:06

    here is a one-liner that checks one file $FilePath and returns if it is a symlink or not, works for files and directories

    if((Get-ItemProperty $FilePath).LinkType){"symboliclink"}else{"normal path"}
    

提交回复
热议问题