Updated cd-repos.ps1, cd-scripts.ps1, and new-junction.ps1

This commit is contained in:
Markus Fleschutz 2025-03-19 12:36:06 +01:00
parent 225a1ae902
commit 2e646cda41
3 changed files with 7 additions and 7 deletions

View File

@ -29,7 +29,7 @@ try {
$path = Resolve-Path $path $path = Resolve-Path $path
Set-Location "$path" Set-Location "$path"
$subfolders = Get-ChildItem $path -attributes Directory $subfolders = Get-ChildItem $path -attributes Directory
"📂$path entered, containing $($subfolders.Count) subfolders." "📂$path entered (has $($subfolders.Count) subfolders)."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0])" "⚠️ Error: $($Error[0])"

View File

@ -16,7 +16,7 @@ try {
$path = Resolve-Path "$PSScriptRoot" $path = Resolve-Path "$PSScriptRoot"
if (-not(Test-Path "$path" -pathType container)) { throw "PowerShell scripts folder at 📂$path doesn't exist (yet)" } if (-not(Test-Path "$path" -pathType container)) { throw "PowerShell scripts folder at 📂$path doesn't exist (yet)" }
$files = Get-ChildItem $path -attributes !Directory $files = Get-ChildItem $path -attributes !Directory
"📂$path entered, containing $($files.Count) scripts." "📂$path entered (has $($files.Count) scripts)."
Set-Location "$path" Set-Location "$path"
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -9,7 +9,7 @@
Specifies the path to the target directory Specifies the path to the target directory
.EXAMPLE .EXAMPLE
PS> ./new-junction.ps1 C:\User\Joe\D_drive D: PS> ./new-junction.ps1 C:\User\Joe\D_drive D:
Created a new junction 'C:\User\Joe\D_drive', linking to 📂D: New junction 'C:\User\Joe\D_drive' created, linking to: 📂D:
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -19,13 +19,13 @@
param([string]$junction = "", [string]$targetDir = "") param([string]$junction = "", [string]$targetDir = "")
try { try {
if ($junction -eq "" ) { $symlink = Read-Host "Enter path and filename of the new junction" } if ($junction -eq "" ) { $junction = Read-Host "Enter the new junction's path and filename" }
if ($targetDir -eq "" ) { $target = Read-Host "Enter the path to the target directory" } if ($targetDir -eq "" ) { $target = Read-Host "Enter the path to the target directory " }
New-Item -path "$symlink" -itemType Junction -value "$targetDir" New-Item -path "$junction" -itemType Junction -value "$targetDir"
if ($lastExitCode -ne 0) { throw "Command 'New-Item' has failed" } if ($lastExitCode -ne 0) { throw "Command 'New-Item' has failed" }
"Created a new junction '$symlink', linking to 📂$targetDir" "New junction '$junction' created, linking to: 📂$targetDir"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"