Quickly view all symbolic links, junction points and hard links in a folder using PowerShell

Date posted: 2020-06-02
Last updated: 2026-10-09

When you migrate a file server and transfer data, you may need to recreate junction points, as they cannot be copied using (for example) Robocopy.exe. This makes it a must to know where you have junction points, and NTFS hard and soft links. This is where PowerShell comes to the rescue.

How to find and view all symbolic, soft links, junction points and hard links in a folder in Windows Server quickly? Use dir /al /s /b or PowerShell.

When you migrate a file server and transfer data, you may need to recreate junction points, as they cannot be copied using (for example) Robocopy.exe. This makes it a must to know where you have junction points, and NTFS hard and soft links. This is where PowerShell comes to the rescue.

Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

Dir displays a list of files and subdirectories in a directory. The /A switch is display files with specified attributes, and L is for Reparse Points attribute. Use this in one switch: /al.

Use /s to display files in the specified directory and all subdirectories (e.g recursive), and /b to leave out heading information and summary.

Give it a try:

C:\>dir /al /b
Documents and Settings

In PowerShell you find out about junction points, symbolic links and hard links using Get-ChildItem's LinkType filter:

Get-ChildItem . -Recurse -Force `
  | ?{ $_.LinkType } `
  | Select FullName, LinkType, Target

Or an example without recursive:

PS C:\Users\Jan Reilink> Get-ChildItem . -Force `
>>   | ?{ $_.LinkType } `
>>   | Select FullName, LinkType, Target

FullName                              LinkType Target
-------- -------- ------
C:\Users\Jan Reilink\Application Data Junction C:\Users\Jan Reilink\AppData\Roaming
C:\Users\Jan Reilink\Cookies          Junction C:\Users\Jan Reilink\AppData\Local\Microsoft\Windows\INetCookies
C:\Users\Jan Reilink\Local Settings   Junction C:\Users\Jan Reilink\AppData\Local
C:\Users\Jan Reilink\My Documents     Junction C:\Users\Jan Reilink\Documents
C:\Users\Jan Reilink\NetHood          Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\Network Shortcuts
C:\Users\Jan Reilink\PrintHood        Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
C:\Users\Jan Reilink\Recent           Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\Recent
C:\Users\Jan Reilink\SendTo           Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\SendTo
C:\Users\Jan Reilink\Start Menu       Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\Start Menu
C:\Users\Jan Reilink\Templates        Junction C:\Users\Jan Reilink\AppData\Roaming\Microsoft\Windows\Templates

On Linux you run into the same issue when copying data: recursive scp doesn't preserve symbolic links, but copies their targets as normal files and directories. Read Recursive scp and symlinks for how to transfer them intact with tar over ssh.

Working with file attributes in PowerShell

I write these posts in my spare time, based on real problems from my day job as a sysadmin. If this one saved you some debugging time, a small donation is much appreciated. Thanks! 🙏

Leave a Comment