Junctions

Quickly view all symbolic links, junction points and hard links in a folder using 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.

Home » Windows Server » Quickly view all symbolic links, junction points and hard links in a folder using PowerShell

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
Jan Reilink
Jan Reilink

In my day to day work, I’m a systems administrator – DevOps / SRE and applications manager at Embrace – The Human Cloud. At Embrace we develop, maintain and host social intranets for our clients. Provide digital services and make working more efficient within various sectors.

Read why we can use your help and support ❤️

Articles: 173