views:

1742

answers:

3

Can Powershell 1.0 create hard and soft links analogous to the unix variety? If this isn't built in, can someone point me to a site that has a ps1 script that mimics this? This is a nessary function of any good shell, IMHO. :)

+3  A: 

No it isn't built into PowerShell and the utility mklink on Vista/Win7 is built directly into cmd.exe. You can use the PowerShell Community Extensions (free). There are several cmdlets for reparse points of various types: New-HardLink, New-SymLink, New-Junction, Remove-ReparsePoint and others.

Keith Hill
Good try. Though if you want to run XP or W2K3 server in either x32 or x64, New-Symlink dosen't work. In XP it will politely tell you that you should be running Vista for this command. In W2K3 server, it flat out breaks.
Mike T
That's because XP doesn't support symlinks. That's a feature new to Vista. I believe that W2K3 server doesn't support symlinks either. You have to step up to W2K8 server to get symlink support. I'll look into why new-symlink is bombing on W2k3, it should error with a similar message to XP.
Keith Hill
I tried new-junction and that will work for me. Too bad the link functionality doesn't degrade to junctions in XP and W2K3
Mike T
on further use of new-junction... I get a junction to the new parse point. However ls (or get-childitem) errors stating that.."The filename, directory name, or volume label syntax is incorrect" If I try and enter a subdirectory from there.
Mike T
+1  A: 

you can use the utility:

c:\Windows\system32\fsutil.exe create hardlink
Cheeso
It will require elevated privileges, though. Creating hardlinks usually doesn't.
Joey
+3  A: 

The Junction command line utility from Sysinternals makes creating and deleting symbolic (soft)links easy. Hard Links and Junctions in Windows.

notandy
The use of this utility correctly allows me to junction another directory and traverse it's subdirectories successfully. All in XP and W2K3. Just add the exe to a directory in your PATH and call it like normal.
Mike T