Improve the done output

This commit is contained in:
Markus Fleschutz 2021-08-24 20:46:03 +02:00
parent 13d4bc48e3
commit 86a0db9640
31 changed files with 59 additions and 47 deletions

View File

@ -18,7 +18,8 @@ try {
if ($File -eq "" ) { $File = read-host "Enter path to file" }
$Result = get-filehash $File -algorithm MD5
"MD5 hash is" $Result.Hash
"✔️ MD5 hash is" $Result.Hash
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -18,7 +18,8 @@ try {
if ($File -eq "" ) { $File = read-host "Enter the filename" }
$Result = get-filehash $File -algorithm SHA1
write-output "SHA1 hash is" $Result.Hash
"✔️ SHA1 hash is" $Result.Hash
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -18,7 +18,8 @@ try {
if ($File -eq "" ) { $File = read-host "Enter the filename" }
$Result = get-filehash $File -algorithm SHA256
write-output "SHA256 hash is:" $Result.Hash
"✔️ SHA256 hash is:" $Result.Hash
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -12,17 +12,18 @@
License: CC0
#>
param([string]$Text = "")
if ($Text -eq "" ) { $Text = read-host "Enter the memo text to add" }
param([string]$text = "")
try {
if ($text -eq "" ) { $text = read-host "Enter the memo text to add" }
$Path = "$HOME/Memos.csv"
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
$User = $(whoami)
$Line = "$Time,$User,$Text"
$Line = "$Time,$User,$text"
if (-not(test-path "$Path" -pathType leaf)) {
write-output "Time,User,Text" > "$Path"
write-output "Time,User,text" > "$Path"
}
write-output $Line >> "$Path"

View File

@ -14,9 +14,9 @@
param([string]$Drive = "", [int]$MinLevel = 20) # minimum level in GB
if ($Drive -eq "" ) { $Drive = read-host "Enter drive to check" }
try {
if ($Drive -eq "" ) { $Drive = read-host "Enter drive to check" }
$DriveDetails = (get-psdrive $Drive)
[int]$Free = (($DriveDetails.Free / 1024) / 1024) / 1024
[int]$Used = (($DriveDetails.Used / 1024) / 1024) / 1024

View File

@ -16,15 +16,13 @@
param([string]$Drive = "")
if ($Drive -eq "" ) {
$Drive = read-host "Enter drive (letter) to check"
}
try {
if ($Drive -eq "" ) { $Drive = read-host "Enter drive (letter) to check" }
$Result = repair-volume -driveLetter $Drive -scan
if ($Result -ne "NoErrorsFound") { throw "'repair-volume' failed" }
write-host -foregroundColor green "✔️ file system on drive $Drive is clean"
"✔️ file system on drive $Drive is clean"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -24,11 +24,10 @@ function IsIPv4AddressValid { param([string]$IP)
}
try {
if ($Address -eq "" ) {
$Address = read-host "Enter IPv4 address to validate"
}
if ($Address -eq "" ) { $Address = read-host "Enter IPv4 address to validate" }
if (IsIPv4AddressValid $Address) {
write-host -foregroundColor green "OK - IPv4 address $Address is valid"
"✔️ IPv4 address $Address is valid"
exit 0
} else {
write-warning "Invalid IPv4 address: $Address"

View File

@ -41,7 +41,7 @@ try {
$Address = read-host "Enter IPv6 address to validate"
}
if (IsIPv6AddressValid $Address) {
write-host -foregroundColor green "OK - IPv6 address $Address is valid"
"✔️ IPv6 address $Address is valid"
exit 0
} else {
write-warning "Invalid IPv6 address: $Address"

View File

@ -29,7 +29,7 @@ try {
$MAC = read-host "Enter MAC address to validate"
}
if (IsMACAddressValid $MAC) {
write-host -foregroundColor green "OK - MAC address $MAC is valid"
"✔️ MAC address $MAC is valid"
exit 0
} else {
write-warning "Invalid MAC address: $MAC"

View File

@ -34,7 +34,8 @@ try {
}
$SymlinksTotal++
}
write-host -foregroundColor green "OK - found $SymlinksTotal symlinks total, $SymlinksBroken symlinks are broken"
"✔️ found $SymlinksTotal symlinks total, $SymlinksBroken symlinks are broken"
exit $SymlinksBroken
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -18,7 +18,7 @@ try {
sfc /verifyOnly
if ($lastExitCode -ne "0") { throw "'sfc /verifyOnly' failed" }
write-host -foregroundColor green "✔️ checked Windows system files"
"✔️ checked Windows system files"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -34,7 +34,8 @@ try {
write-warning "Invalid XML file"
exit 1
}
write-host -foregroundColor green "OK - XML file is valid"
"✔️ XML file is valid"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -158,16 +158,13 @@ Param(
try {
if ($Path -eq "" ) {
$Path = read-host "Enter path to file"
}
if ($Password -eq "" ) {
$Password = read-host "Enter password"
}
if ($Path -eq "" ) { $Path = read-host "Enter path to file" }
if ($Password -eq "" ) { $Password = read-host "Enter password" }
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
DecryptFile "$Path" -algorithm AES -keyAsPlainText $PasswordBase64 -removeSource
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -20,7 +20,7 @@ try {
}
$null = new-item @GodModeSplat
"✔️ new icon added to the desktop"
"✔️ enabled god mode - see the new desktop icon"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -152,7 +152,7 @@ try {
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
EnryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -32,7 +32,7 @@ try {
"&color=" + $ForegroundColor + "&bgcolor=" + $BackgroundColor.Text + `
"&format=" + $FileFormat), $NewFile)
write-host -foregroundColor green "Done - QR code has been written to $NewFile"
"✔️ wrote QR code to $NewFile"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -17,6 +17,8 @@
try {
[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.Application]::SetSuspendState("Hibernate", $false, $false);
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -23,7 +23,8 @@ try {
write-output $_.FullName
$Count++
}
write-host -foregroundColor green "OK - found $Count empty file(s)"
"✔️ found $Count empty file(s)"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -29,7 +29,7 @@ try {
$PathToRepo = "$PSScriptRoot/.."
ListScripts "$PathToRepo/Data/scripts.csv" | format-table -property "PowerShell Script",Description
write-host -foregroundColor green "OK - $($global:NumScripts) PowerShell scripts total"
"✔️ $($global:NumScripts) PowerShell scripts total"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -23,7 +23,8 @@ try {
echo ------------------------------------------------------------------------------
echo.
write-host -foregroundColor green "Done - synced to %DST_DIR%"
"✔️ synced to %DST_DIR%"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -53,7 +53,8 @@ try {
Invoke-Expression $Cmd > $Filename
$DevInfo++
}
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -40,6 +40,7 @@ try {
Remove-Item -Path $Folder.Object.FullName -Force
}
}
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -27,6 +27,7 @@ try {
$msg.subject = $Subject
$msg.body = $Body
$smtp.Send($msg)
"✔️ Message sent."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -31,7 +31,7 @@ try {
$Stream.Close()
$Socket.Close()
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,8 @@ try {
$EncodedText = [Text.Encoding]::ASCII.GetBytes($Message)
$SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints)
$Socket.Close()
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -22,7 +22,8 @@ try {
./write-big "T-$i seconds"
start-sleep -s 1
}
write-host -foregroundColor green "Done - $Seconds seconds countdown finished"
"✔️ $Seconds seconds countdown finished"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -58,10 +58,11 @@ function SetWallPaper {
}
try {
if ($ImageFile -eq "" ) {
$ImageFile = read-host "Enter path to image file"
}
if ($ImageFile -eq "" ) { $ImageFile = read-host "Enter path to image file" }
SetWallPaper -Image $ImageFile -Style $Style
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -23,7 +23,8 @@ try {
& "$PSScriptRoot/switch-shelly1.ps1" $IPaddress off 0
start-sleep -s 60
}
write-host -foregroundColor green "Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -47,7 +47,7 @@ try {
# Start-Process nohup 'ipfs daemon'
Start-Process nohup -ArgumentList 'ipfs','daemon' -RedirectStandardOutput "$HOME/console.out" -RedirectStandardError "$HOME/console.err"
"Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -21,7 +21,7 @@ try {
$Result = Invoke-RestMethod "http://$($Host)/relay/0?turn=$($TurnMode)&timer=$($Timer)"
write-host -foregroundColor green "✔️ Shelly1 device at $Host switched to $TurnMode for $Timer second(s)"
"✔️ Shelly1 device at $Host switched to $TurnMode for $Timer second(s)"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -48,7 +48,8 @@ try {
#sudo do-release-upgrade -d # to latest supported release
sudo reboot
}
"Done."
"✔️ Done."
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"