How to Create Symbolic Links in PowerShell

  1. Creating Symbolic Links Using PowerShell
  2. Creating Directory Junctions Using PowerShell
  3. Creating Hard Links Using PowerShell
How to Create Symbolic Links in PowerShell

Symbolic links are used in redirecting files or one folder to another location to make our data accessible from various file system locations without physically moving your data.

This article will guide you through creating symbolic links using Windows PowerShell.

In Windows 10 (or Windows Server 2016), Microsoft released a new command in PowerShell called New-Item, which creates symbolic links.

Call the New-Item cmdlet to create symbolic links and pass in the item type SymbolicLink. Next, replace the Link argument with the path to the symbolic link we want to make (including the file name and its extension).

Finally, replace the Target portion with the path (relative or absolute) that the new link refers to.

New-Item -ItemType SymbolicLink -Path "Link" -Target "Target"

You can also use PowerShell to create directory junctions and hard links, which we will discuss in the article’s next section.

Creating Directory Junctions Using PowerShell

We must first understand what link is a directory junction and when it is used.

A Directory Junction is an older symbolic link type that does not support UNC paths in Windows 2000 and later NT-based Windows systems.

However, the preferred option is a symbolic directory link that supports UNC and relative paths for machines newer than Windows Vista.

The exact process applies when creating directory junctions in PowerShell. We have to replace the ItemType value with Junction.

New-Item -ItemType Junction -Path "Link" -Target "Target"

Same with our previous methods, we need to replace the ItemType value with HardLink.

New-Item -ItemType HardLink -Path "Link" -Target "Target"

Hard links have more limitations than directory junctions. Aside from it does not support UNC paths, we can only create a hard link for files but not for folders.

Windows Vista and later, directory junctions link older directory paths like C:\Documents and Settings to newer paths like C:\Users\user01\Documents. Symbolic links are also used to connect C:\Users\All Users to C:\ProgramData.

Since Windows Vista, hard links are also widely used by Windows and its Servicing mechanism. In addition, many system files are hard-linked to files inside the Windows Component Store folder.

Marion Paul Kenneth Mendoza avatar Marion Paul Kenneth Mendoza avatar

Marion specializes in anything Microsoft-related and always tries to work and apply code in an IT infrastructure.

LinkedIn