From 72b8c58768d2ed9f7653460d95bbe5867dc45984 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 26 Feb 2025 15:26:32 +0100 Subject: [PATCH] Updated new-junction.ps1 --- scripts/new-junction.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/new-junction.ps1 b/scripts/new-junction.ps1 index 0bacc7f5..17262529 100755 --- a/scripts/new-junction.ps1 +++ b/scripts/new-junction.ps1 @@ -2,30 +2,30 @@ .SYNOPSIS Create a junction .DESCRIPTION - This PowerShell script creates a new junction, linking to a target. + This PowerShell script creates a new junction, linking to a target folder. The target folder can reside on another disk. .PARAMETER junction - Specifies the file path to the new junction -.PARAMETER target - Specifies the file path to the target + Specifies the path and filename of the new junction +.PARAMETER targetDir + Specifies the path to the target directory .EXAMPLE - PS> ./new-junction.ps1 D:\Win10 C:\Windows - ✅ Created new junction 'D:\Windows' linking to: C:\Windows + PS> ./new-junction.ps1 C:\User\Joe\D_drive D: + ✅ Created a new junction 'C:\User\Joe\D_drive', linking to 📂D: .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #> -param([string]$junction = "", [string]$target = "") +param([string]$junction = "", [string]$targetDir = "") try { - if ($junction -eq "" ) { $symlink = Read-Host "Enter new junction filename" } - if ($target -eq "" ) { $target = Read-Host "Enter path to target" } + if ($junction -eq "" ) { $symlink = Read-Host "Enter path and filename of the new junction" } + if ($targetDir -eq "" ) { $target = Read-Host "Enter the path to the target directory" } - New-Item -path "$symlink" -itemType Junction -value "$target" + New-Item -path "$symlink" -itemType Junction -value "$targetDir" if ($lastExitCode -ne 0) { throw "Command 'New-Item' has failed" } - "✅ Created new junction '$symlink' linking to: $target" + "✅ Created a new junction '$symlink', linking to 📂$targetDir" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"