New-Symlink
Creates a new symlink
param([string]$symlink = "", [string]$target = "")
try {
if ($symlink -eq "" ) { $symlink = Read-Host "Enter new symlink filename" }
if ($target -eq "" ) { $target = Read-Host "Enter path to target" }
New-Item -path "$symlink" -itemType SymbolicLink -value "$target"
if ($lastExitCode -ne 0) { throw "Command 'New-Item' has failed" }
"? Created new symlink '$symlink' linking to: $target"
exit 0 # success
} catch {
"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}Specifies the file path to the new symlink file
Specifies the file path to the target