Tools for managing file system links in Windows PowerShell.
C#
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Properties
bin
build
src
PowerShellCmdlets.csproj
README.mkd

README.mkd

PSLinkTools

PSLinkTools is a PowerShell SnapIn that provides a set of cmdlets for creating and manipulating file system links.

Building

Microsoft's Windows PowerShell 2.0 SDK must be installed.

In PowerShell, navigate to the primary directory of this project, then run

PS> .\build\buildLinkTools.ps1

Settings in the script may need adjusting depending on x86/x64, and/or any non-standard installation directories.

Registering

Once built, the LinkTools.dll must be registered.

In PowerShell, navigate to the primary directory of this project, then run

PS> .\build\registerLinkTools.ps1

Again, settings in the script may need adjusting depending on x86/x64, and/or any non-standard installation directories.

Using In PowerShell

Once registered, the LinkTools SnapIn is enabled (per session) by running:

PS> Add-PSSnapin LinkTools

The New-Symlink cmdlet has the following arguments:

  • LiteralPath (required) - this is the path to the symlink that is to be created
  • Target (required) - this is the path to the file or directory that is to be linked to (see MSDN documentation on accepted paths)
  • Type (optional) - either "File" (default) or "Directory"; if linking to a directory, the Type must be specified as "Directory"

Example:

PS> New-Symlink -LiteralPath 'C:\Users\Gotthold\Desktop\Minna.pdf' -Target 'C:\Users\Gotthold\Books\Dramas\Lessing - Minna von Barnhelm.pdf'

or, assuming the order of the arguments,

PS> New-Symlink 'C:\Users\Gotthold\Desktop\Minna.pdf' 'C:\Users\Gotthold\Books\Dramas\Lessing - Minna von Barnhelm.pdf'

or, using a directory relative path,

PS> New-Symlink 'C:\Users\Gotthold\Desktop\Minna.pdf' -Target '..\Books\Dramas\Lessing - Minna von Barnhelm.pdf'

or, as a root relative path,

PS> New-Symlink 'C:\Users\Gotthold\Desktop\Minna.pdf' '\Users\Gotthold\Books\Dramas\Lessing - Minna von Barnhelm.pdf'

Note: The New-Symlink command does not require the Target to exist. To illustrate a consequence of this, if one executed the following command:

PS> New-Symlink -LiteralPath 'C:\Users\All Users\Desktop\Windows' -Target 'C:\Windows'

the result would be a link on the desktop to a file in the root of the C drive named Windows, whether or not that file exists (probably not).

To remove the SnapIn during a session, run:

PS> Remove-PSSnapin LinkTools

Release Notes

Version 1

  • New-Symlink cmdlet - straight interface to the CreateSymbolicLink method found in kernel32.dll

About

The main reason I wrote this is because neither mklink nor PSCX's New-Symlink have proper support for root relative symbolic links, which are really useful. Hence, that probably explains why this is the only command in here as of version 1. ;)

Copyright Stuff

Copyright (c) 2012 Mervin Fansler

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.