Skip to content

Leverage new API for creating symlink without administrator privileges on Windows #2845

@joeyaiello

Description

@joeyaiello

Just saw this get posted today: https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/

We should opt-in to this API so that we're uniform across all platforms in allowing non-admins to create links.

Steps to reproduce

Try to create a symlink as a non-admin. You'll get a permission denied.

Expected behavior

(as non-admin)

PS C:\temp> New-Item -type SymbolicLink -Path link -Value source

    Directory: C:\temp
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a---l        12/5/2016   6:39 PM              0 link

Actual behavior

PS C:\temp> New-Item -type SymbolicLink -Path link -Value source
New-Item : Administrator privilege required for this operation.
At line:1 char:1
+ New-Item -type SymbolicLink -Path link -Value source
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\temp\source:String) [New-Item], UnauthorizedAccessException
    + FullyQualifiedErrorId : NewItemSymbolicLinkElevationRequired,Microsoft.PowerShell.Commands.NewItemCommand

Environment data

All versions of Windows PowerShell 5.x and PowerShell Core 6.0.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions