Improve the error message line

This commit is contained in:
Markus Fleschutz
2022-04-13 12:06:32 +02:00
parent 2e86cb0fa4
commit 04738077fe
284 changed files with 293 additions and 294 deletions

View File

@ -12,14 +12,14 @@
Author: Markus Fleschutz / License: CC0
#>
function Get-CurrentUserSID { [CmdletBinding()] param()
function GetCurrentUserSID { [CmdletBinding()] param()
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value
}
try {
$Path = 'C:\$Recycle.Bin\' + "$(Get-CurrentUserSID)"
$Path = 'C:\$Recycle.Bin\' + "$(GetCurrentUserSID)"
if (-not(test-path "$Path" -pathType container)) {
throw "Recycle bin folder at 📂$Path doesn't exist (yet)"
}
@ -27,6 +27,6 @@ try {
"📂$Path"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}