Improve the cd-* scripts

This commit is contained in:
Markus Fleschutz
2021-10-19 08:24:17 +02:00
parent 32d2b76abb
commit e9bfd8cf10
19 changed files with 194 additions and 118 deletions

View File

@ -18,11 +18,15 @@ function Get-CurrentUserSID { [CmdletBinding()] param()
}
$TargetDir = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
if (-not(test-path "$TargetDir" -pathType container)) {
write-warning "Sorry, the user's recycle bin folder at 📂$TargetDir does not exist (yet)"
try {
$TargetDir = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
if (-not(test-path "$TargetDir" -pathType container)) {
throw "Recycle bin folder at 📂$TargetDir doesn't exist (yet)"
}
set-location "$TargetDir"
"📂$TargetDir"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}
set-location "$TargetDir"
"📂$TargetDir"
exit 0 # success