Share via

Cannot create symbolic link on Windows 11 with Powershell 7 - CommandNotFoundException

Anonymous
2023-08-08T15:11:03+00:00

I installed Powershell 7 and was trying to

mklink /D \kang C:\Users\Me\Documents\Learn\Java\Sandbox\src\mammal\kangaroo

mklink : The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program.

Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:2

  • mklink /D \kang C:\Users\Me\Documents\Learn\Java\Sandbox\src\mamma ...
  • 
        + CategoryInfo          : ObjectNotFound: (mklink:String) [], CommandNotFoundException 
    
        + FullyQualifiedErrorId : **CommandNotFoundException** 
    
    

I had to use Command Prompt with Admin privileges to do this.

How to get these commands to work in Powershell7?

Windows for home | Windows 11 | Performance and system failures

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Ramesh 176.1K Reputation points Volunteer Moderator
    2023-08-08T15:19:50+00:00

    Mklink is an internal Command Processor command. To execute the command in PowerShell, please try the cmd.exe /c prefix.

    Example:

    cmd /c mklink /d test d:\test

    10+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-08-08T21:34:38+00:00

    Mklink is an internal Command Processor command. To execute the command in PowerShell, please try the cmd.exe /c prefix.

    Example:

    cmd /c mklink /d test d:\test

    Did not work for me. In Powershell 7, I got this error:

    cmd /c mklink /D \kang C:\Users\Me\Documents\Learn\Java\Sandbox\src\mammal\kangaroo

    You do not have sufficient privilege to perform this operation.

    I opened Powershell in Admin mode and tried again, but still got this error

    mklink : The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program.

    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    At line:1 char:1

    5 people found this answer helpful.
    0 comments No comments
  3. Brink 16,560 Reputation points Volunteer Moderator
    2023-08-08T18:58:50+00:00

    Hello,

    Double check using the tutorial below to see if it may help using the command to create a symbolic link.

    https://www.tenforums.com/tutorials/131182-create-soft-hard-symbolic-links-windows.html

    1 person found this answer helpful.
    0 comments No comments
  4. Ramesh 176.1K Reputation points Volunteer Moderator
    2023-08-09T04:06:51+00:00

    Can you post a screenshot of the error in the admin PowerShell window?

    I tested in the inbox version of PowerShell (5.1.19041.3031) and PS7, and the command worked correctly in both.

    Alternatively, use the New-Item cmdlet in PS.

    New-Item (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-item?view=powershell-7.3

    -ItemType

    Specifies the provider-specified type of the new item. The available values of this parameter depend on the current provider you are using.

    If your location is in a FileSystem drive, the following values are allowed:

    • File
    • Directory
    • SymbolicLink
    • Junction
    • HardLink
    0 comments No comments