symlink - Find out whether a file is a symbolic link in PowerShell -


I have a PowerShell script that is running a directory tree, and sometimes I have helpful files, which are hardlinks , Which should not be processed. Is there a simple way to know if a file (i.e., System.IO.FileInfo ) is a hard link?

If not, will it be easy symbolic link?

Try it out:

  function test - presspoint ([string ] $ Path) {$ file = Get-item $ path -forces E-content content Returns [bool] ($ file.Attributes -band [IO.FileAttributes] :: ReparsePoint)}  

This is a very low implementation, but it should do the trick. Note that this does not distinguish between hard links and symbolic links. Below, they both take advantage of the bus.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -