The Computer Oracle

How do you create a new symlink in windows 10 using powershell (not mklink.exe)?

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Track title: CC L Beethoven - Piano Sonata No 8 in C

--

Chapters
00:00 Question
00:29 Accepted answer (Score 60)
01:29 Answer 2 (Score 57)
02:11 Thank you

--

Full question
https://superuser.com/questions/1307360/...

Answer 1 links:
https://learn.microsoft.com/windows-serv...
https://learn.microsoft.com/powershell/m...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows10 #powershell

#avk47



ACCEPTED ANSWER

Score 65


  1. Start powershell as admin
  2. You need to know 1) the path to target of the link 2) path to location where you want the link 3) the name you want to use to refer to the link.
  3. PS C:\> new-item -itemtype symboliclink -path <path to location> -name <the name> -value <path to target>

Example: If you're in c:\drivers\AMD and you want to link in f:\driver\olddrivers, then you would go

PS C:\> new-item -itemtype symboliclink -path . -name OldDrivers -value f:\driver\olddrivers

And wind up with a symlink path of c:\driver\AMD\OldDrivers




ANSWER 2

Score 60


Use the New-Item cmdlet and specify the appropriate ItemType of SymbolicLink, HardLink, or Junction. Note that these are only available from PowerShell 5.1 or newer.

+-----------------------+-----------------------------------------------------------+
| mklink syntax         | PowerShell equivalent                                     |
+-----------------------+-----------------------------------------------------------+
| mklink Link Target    | New-Item -ItemType SymbolicLink -Name Link -Target Target |
| mklink /D Link Target | New-Item -ItemType SymbolicLink -Name Link -Target Target |
| mklink /H Link Target | New-Item -ItemType HardLink -Name Link -Target Target     |
| mklink /J Link Target | New-Item -ItemType Junction -Name Link -Target Target     |
+-----------------------+-----------------------------------------------------------+