Improve both scripts

This commit is contained in:
Markus Fleschutz 2021-05-13 10:33:34 +02:00
parent 6230f7ccc2
commit 3b9c9b68c2
2 changed files with 4 additions and 3 deletions

View File

@ -13,12 +13,12 @@ function ListEarthquakes {
write-progress "Loading data ..."
$Earthquakes = (Invoke-WebRequest -Uri "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -UserAgent "curl" ).Content | ConvertFrom-CSV
foreach ($Quake in $Earthquakes) {
new-object PSObject -Property @{ Magnitude=$Quake.mag; Depth=$Quake.depth; Place=$Quake.place; Time=$Quake.time }
new-object PSObject -Property @{ Mag=$Quake.mag; Depth=$Quake.depth; Location=$Quake.place; Time=$Quake.time }
}
}
try {
ListEarthquakes | format-table -autoSize -property Magnitude,Depth,Place,Time
ListEarthquakes | format-table -property Mag,Location,Depth,Time -autoSize
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -23,7 +23,8 @@ try {
"$Time $User $Text"
}
} else {
"Sorry, no $Path file found"
"Sorry, no memos saved yet"
exit 1
}
exit 0
} catch {