diff --git a/scripts/cd-repos.ps1 b/scripts/cd-repos.ps1 index 6887d421..691824ff 100755 --- a/scripts/cd-repos.ps1 +++ b/scripts/cd-repos.ps1 @@ -1,13 +1,13 @@ <# .SYNOPSIS - Sets the working directory to the user's repos folder + Sets the working directory to the Git repos folder .DESCRIPTION - This PowerShell script changes the working directory to the user's Git repositories folder. + This PowerShell script changes the working directory to the Git repositories folder. .PARAMETER subpath Specifies an additional relative subpath (optional) .EXAMPLE PS> ./cd-repos.ps1 - 📂C:\Users\Markus\Repos + 📂C:\Repos .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -25,6 +25,10 @@ try { $path = "~/source/repos/" } elseif (Test-Path "/Repos/" -pathType Container) { $path = "/Repos/" + } elseif (Test-Path "C:/Repos" -pathType Container) { + $path = "C:/Repos" + } elseif (Test-Path "C:/Repositories" -pathType Container) { + $path = "C:/Repositories" } else { throw "The folder for Git repositories doesn't exist (yet)" } diff --git a/scripts/new-symlink.ps1 b/scripts/new-symlink.ps1 index afc83f2c..70e56132 100755 --- a/scripts/new-symlink.ps1 +++ b/scripts/new-symlink.ps1 @@ -4,12 +4,12 @@ .DESCRIPTION This PowerShell script creates a new symbolic link file, linking to a target. .PARAMETER symlink - Specifies the path to the new symlink file + Specifies the file path to the new symlink file .PARAMETER target - Specifies the path to the target + Specifies the file path to the target .EXAMPLE PS> ./new-symlink.ps1 C:\User\Markus\Windows C:\Windows - ✅ New symlink file 'C:\User\Markus\Windows' created, linking to: C:\Windows + ✅ Created new symlink file 'C:\User\Markus\Windows', linking to: C:\Windows .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -23,8 +23,9 @@ try { 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" } - "✅ New symlink file '$symlink' created, linking to: $target" + "✅ Created new symlink file '$symlink', linking to: $target" exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"