Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
741 views
in Technique[技术] by (71.8m points)

symlink - powershell to resolve junction target path

In PowerShell, I need resolve the target path of a junction (symlink).

for example, say I have a junction c:someJunction whose target is c:emparget

I tried variations of $junc = Get-Item c:someJunction, but was only able to get c:someJunction

How do I find the target path of the junction, in this example c:emparget, of a given junction?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

New-Item, Remove-Item, and Get-ChildItem have been enhanced to support creating and managing symbolic links. The -ItemType parameter for New-Item accepts a new value, SymbolicLink. Now you can create symbolic links in a single line by running the New-Item cmdlet.

What's New in Windows PowerShell v5

I've checked the symlink support on the my Windows 7 machine, it's works fine.

PS> New-Item -Type SymbolicLink -Target C: -Name TestSymlink


    Directory: C:UsersskokhanovskiyDesktop


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----l       06.09.2016     18:27                TestSymlink

Get target of the symbolic link as easy as to create it.

> Get-Item .TestSymlink | Select-Object -ExpandProperty Target
C:

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...