Improve executing other scripts

This commit is contained in:
Markus Fleschutz 2021-04-07 14:45:10 +02:00
parent 6cf41e4221
commit 381c3b850f
6 changed files with 15 additions and 15 deletions

View File

@ -10,24 +10,24 @@ $Hostname = $(hostname)
$Healthy = 1
"Checking health of $Hostname ..."
& ./check-swap-space.ps1
& "$PSScriptRoot/check-swap-space.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 }
if ($IsLinux) {
& ./check-drive-space.ps1 /
& "$PSScriptRoot/check-drive-space.ps1" /
if ($lastExitCode -ne "0") { $Healthy = 0 }
} else {
& ./check-drive-space.ps1 C
& "$PSScriptRoot/check-drive-space.ps1" C
if ($lastExitCode -ne "0") { $Healthy = 0 }
}
& ./check-cpu-temp.ps1
& "$PSScriptRoot/check-cpu-temp.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 }
& ./check-dns-resolution.ps1
& "$PSScriptRoot/check-dns-resolution.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 }
& ./check-ping.ps1
& "$PSScriptRoot/check-ping.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 }
if ($Healthy) {

View File

@ -7,10 +7,10 @@
#>
try {
& write-big.ps1 "PowerShell"
& "$PSScriptRoot/write-big.ps1" "PowerShell"
& write-animated.ps1 "Welcome to PowerShell"
& write-animated.ps1 "Feel the power of the console and scripting"
& "$PSScriptRoot/write-animated.ps1" "Welcome to PowerShell"
& "$PSScriptRoot/write-animated.ps1" "Feel the power of the console and scripting"
""
"* Want to learn PowerShell? See the tutorials at: https://www.guru99.com/powershell-tutorial.html"
@ -20,7 +20,7 @@ try {
"* Want sample scripts? See PowerShell Scripts at: https://github.com/fleschutz/PowerShell/"
""
& write-typewriter.ps1 "P.S. PowerShell is looking forward to execute your next command"
& "$PSScriptRoot/write-typewriter.ps1" "P.S. PowerShell is looking forward to execute your next command"
""
exit 0

View File

@ -14,9 +14,9 @@ if ($IPaddress -eq "" ) {
try {
for ([int]$i = 0; $i -lt 1000; $i++) {
& ./switch-shelly1.ps1 $IPaddress on 0
& "$PSScriptRoot/switch-shelly1.ps1" $IPaddress on 0
start-sleep -s 10
& ./switch-shelly1.ps1 $IPaddress off 0
& "$PSScriptRoot/switch-shelly1.ps1" $IPaddress off 0
start-sleep -s 60
}
write-host -foregroundColor green "Done."

View File

@ -8,7 +8,7 @@
try {
[system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US"
& ./speak-english.ps1 "Today is $((Get-Date).ToShortDateString())"
& "$PSScriptRoot/speak-english.ps1" "Today is $((Get-Date).ToShortDateString())"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -16,7 +16,7 @@ try {
$Joke = $Table[$Index].Joke
& ./speak-english.ps1 "$Joke"
& "$PSScriptRoot/speak-english.ps1" "$Joke"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -8,7 +8,7 @@
try {
[system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US"
& ./speak-english.ps1 "It's now $((Get-Date).ToShortTimeString())"
& "$PSScriptRoot/speak-english.ps1" "It's now $((Get-Date).ToShortTimeString())"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"