Added create-symlink.ps1

This commit is contained in:
Markus Fleschutz
2021-02-17 08:24:03 +01:00
parent ea19ee6769
commit f0fe3a50b0
3 changed files with 28 additions and 0 deletions

26
Scripts/create-symlink.ps1 Executable file
View File

@ -0,0 +1,26 @@
#!/bin/powershell
<#
.SYNTAX ./create-symlink.ps1 [<symlink>] [<target>]
.DESCRIPTION creates a symbolic link
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($Symlink = "", $Target = "")
try {
if ($Symlink -eq "" ) {
$Symlink = read-host "Enter filename of symlink"
}
if ($Target -eq "" ) {
$Target = read-host "Enter path to target"
}
new-item -path "$Symlink" -itemType SymbolicLink -Value "$Target"
write-host -foregroundColor green "Done."
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}