Improve the scripts

This commit is contained in:
Markus Fleschutz 2021-04-17 18:54:45 +02:00
parent 9aa997ebf5
commit f78a9390cb
9 changed files with 15 additions and 20 deletions

View File

@ -26,7 +26,7 @@ try {
} elseif ($Temp -lt "0") {
write-warning "$Temp °C CPU temperature is quite low"
} else {
write-host -foregroundColor green "✔️ $Temp °C CPU temperature"
"✔️ $Temp °C CPU temperature"
}
exit 0
} catch {

View File

@ -25,7 +25,7 @@ try {
$Elapsed = $StopWatch.Elapsed
$Average = [math]::round($Count / $Elapsed.Seconds, 1)
write-host -foregroundColor green "✔️ $Average domains/s ($Count domains resolved in $($Elapsed.Seconds) seconds)"
"✔️ $Average domains/s ($Count domains resolved in $($Elapsed.Seconds) seconds)"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -8,9 +8,7 @@
param($Drive = "", [int]$MinLevel = 50) # minimum level in GB
if ($Drive -eq "" ) {
$Drive = read-host "Enter drive to check"
}
if ($Drive -eq "" ) { $Drive = read-host "Enter drive to check" }
try {
$DriveDetails = (get-psdrive $Drive)
@ -22,7 +20,7 @@ try {
write-warning "Drive $Drive has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
exit 1
}
write-host -foregroundColor green "✔️ $Free GB left on drive $Drive ($Used GB of $Total GB used)"
"✔️ $Free GB left on drive $Drive ($Used GB of $Total GB used)"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -31,7 +31,7 @@ if ($lastExitCode -ne "0") { $Healthy = 0 }
if ($lastExitCode -ne "0") { $Healthy = 0 }
if ($Healthy) {
write-host -foregroundColor green "✔️ $Hostname is healthy"
"✔️ $Hostname is healthy"
exit 0
} else {
write-warning "$Hostname is NOT healthy"

View File

@ -25,7 +25,7 @@ try {
}
$Avg = $Avg / $Pings.count
write-host -foregroundColor green "✔️ $Avg ms average ping latency ($Min ms min, $Max ms max)"
"✔️ $Avg ms average ping latency ($Min ms min, $Max ms max)"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -31,7 +31,7 @@ try {
write-warning "Swap space has only $Free GB left to use! ($Used GB out of $Total GB in use, minimum is $MinLevel GB)"
exit 1
}
write-host -foregroundColor green "✔️ $Free GB left on swap space ($Used GB of $Total GB used)"
"✔️ $Free GB left on swap space ($Used GB of $Total GB used)"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -9,7 +9,8 @@
param($RepoDir = "$PWD")
try {
"⏳ Cleaning Git repository $RepoDir from untracked files..."
$RepoDir = resolve-path "$RepoDir/"
"⏳ Cleaning $RepoDir from untracked files..."
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
set-location "$RepoDir"
@ -23,7 +24,7 @@ try {
& git submodule foreach --recursive git clean -fdx
if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" }
write-host -foregroundColor green "✔️ Git repository $RepoDir is clean"
"📂 $RepoDir is clean"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,4 +1,4 @@
#!/usr/bin/pwsh
#!/usr/bin/pwsh
<#
.SYNTAX create-branch.ps1 [<new-branch-name>] [<repo-dir>]
.DESCRIPTION creates a new branch in the current/given Git repository
@ -7,10 +7,7 @@
#>
param($NewBranchName = "", $RepoDir = "$PWD")
if ($NewBranchName -eq "") {
$NewBranchName = read-host "Enter new branch name"
}
if ($NewBranchName -eq "") { $NewBranchName = read-host "Enter new branch name" }
try {
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
@ -35,6 +32,7 @@ try {
& git submodule update --init --recursive
if ($lastExitCode -ne "0") { throw "'git submodule update' failed" }
"🌵 branch $NewBranchName has been created"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -7,10 +7,7 @@
#>
param($NewTagName = "", $RepoDir = "$PWD")
if ($NewTagName -eq "") {
$NewTagName = read-host "Enter new branch name"
}
if ($NewTagName -eq "") { $NewTagName = read-host "Enter new tag name" }
try {
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
@ -32,6 +29,7 @@ try {
& git push origin "$NewTagName"
if ($lastExitCode -ne "0") { throw "Error: 'git push origin $NewTagName' failed!" }
"🔖 tag $NewTagName has been created"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"