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
### SYMBOLIC LINK FILES | |
# Create a new symbolic link file named MySymLinkFile.txt in C:\Temp which links to $pshome\profile.ps1 | |
cd C:\Temp | |
New-Item -ItemType SymbolicLink -Name MySymLinkFile.txt -Target $pshome\profile.ps1 # File | |
# Target is an alias to the Value parameter | |
# Equivalent to above | |
New-Item -ItemType SymbolicLink -Path C:\Temp -Name MySymLinkFile.txt -Value $pshome\profile.ps1 | |
# Equivalent to above | |
New-Item -ItemType SymbolicLink -Path C:\Temp\MySymLinkFile.txt -Value $pshome\profile.ps1 | |
# Equivalent to above | |
New-Item -ItemType SymbolicLink -Name C:\Temp\MySymLinkFile.txt -Value $pshome\profile.ps1 | |
### SYMBOLIC LINK DIRECTORIES | |
# Create a new symbolic link directory named MySymLinkDir in C:\Temp which links to the $pshome folder | |
# ItemType is the same for files and directories - autodetect based on specified target | |
cd C:\Temp | |
New-Item -ItemType SymbolicLink -Name MySymLinkDir -Target $pshome # Directory | |
# Target is an alias to the Value parameter | |
# Similar to above, any combination of Path and Name also works | |
New-Item -ItemType SymbolicLink -Path C:\Temp -Name MySymLinkDir -Value $pshome | |
New-Item -ItemType SymbolicLink -Path C:\Temp\MySymLinkDir -Value $pshome | |
New-Item -ItemType SymbolicLink -Name C:\Temp\MySymLinkDir -Value $pshome | |
### HARD LINKS | |
New-Item -ItemType HardLink -Path C:\Temp -Name MyHardLinkFile.txt -Value $pshome\profile.ps1 | |
# Same combinations of Path and Name allowed as described above | |
### DIRECTORY JUNCTIONS | |
New-Item -ItemType Junction -Path C:\Temp\MyJunctionDir -Value $pshome | |
# REMOVE-ITEM | |
# Works like any other item type | |
# Removes MySymLinkFile.txt | |
Remove-Item C:\Temp\MySymLinkFile.txt | |
# Returns an error as this is a reparse point. | |
Remove-Item C:\Temp\MySymLinkDir | |
# Removes the files in the target directory and MySymLinkDir | |
Remove-Item C:\Temp\MySymLinkDir -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment