Last active
June 23, 2021 22:09
-
-
Save pvspain/6a6d40b354eef2170f27b0fa3304f93f to your computer and use it in GitHub Desktop.
Powershell filesystem symbolic links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## References: | |
# https://stackoverflow.com/questions/9042542/what-is-the-difference-between-ntfs-junction-points-and-symbolic-links | |
# Good feature matrix for symbolic links | |
# https://ss64.com/nt/mklink.html | |
# Microsoft doco on Reparse Points | |
# https://docs.microsoft.com/en-gb/windows/win32/fileio/reparse-points | |
# Powershell 5.1 issue and solution deleting symbolic links... | |
# https://stackoverflow.com/questions/51160864/delete-children-directories-in-powershell-including-symlinks | |
# Hard Link to File | |
New-Item -ItemType HardLink -Path path\to\new-filename -Target path\to\existing-filename | |
# Soft link to File | |
New-Item -ItemType SymbolicLink -Path path\to\new-filename -Target path\to\existing-filename | |
# Soft Link to Directory | |
New-Item -ItemType SymbolicLink -Path path\to\new-directory -Target path\to\existing-directory | |
# Legacy Soft Link to Directory (limited to same computer) | |
New-Item -ItemType Junction -Path path\to\new-directory -Target path\to\existing-directory | |
# Delete a symbolic link | |
# WARNING! Do not use Remove-Item with a symbolic/soft link to a directory as this will delete the directory, not the link! | |
(Get-Item path\to\link).Delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment