From 3d30f791767985b344ebe43be9e1ac0d575709f6 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 16 Oct 2024 08:36:58 +0200 Subject: [PATCH] Improved new-symlink.ps1 --- scripts/new-symlink.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/new-symlink.ps1 b/scripts/new-symlink.ps1 index e5a77495..afc83f2c 100755 --- a/scripts/new-symlink.ps1 +++ b/scripts/new-symlink.ps1 @@ -1,14 +1,15 @@ <# .SYNOPSIS - Creates a new symbolic link file + Creates a new symlink .DESCRIPTION - This PowerShell script creates a new symbolic link file. + This PowerShell script creates a new symbolic link file, linking to a target. .PARAMETER symlink - Specifies the new symlink filename + Specifies the path to the new symlink file .PARAMETER target - Specifies the path to target + Specifies the path to the target .EXAMPLE - PS> ./new-symlink.ps1 C:\Temp\HDD C:\ + PS> ./new-symlink.ps1 C:\User\Markus\Windows C:\Windows + ✅ New symlink file 'C:\User\Markus\Windows' created, linking to: C:\Windows .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -18,12 +19,12 @@ 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" } + 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" + New-Item -path "$symlink" -itemType SymbolicLink -value "$target" - "✅ created new symlink $symlink ⭢ $target" + "✅ New symlink file '$symlink' created, linking to: $target" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"