mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Improve both scripts
This commit is contained in:
parent
6230f7ccc2
commit
3b9c9b68c2
@ -13,12 +13,12 @@ function ListEarthquakes {
|
|||||||
write-progress "Loading data ..."
|
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
|
$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) {
|
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 {
|
try {
|
||||||
ListEarthquakes | format-table -autoSize -property Magnitude,Depth,Place,Time
|
ListEarthquakes | format-table -property Mag,Location,Depth,Time -autoSize
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -23,7 +23,8 @@ try {
|
|||||||
"$Time $User $Text"
|
"$Time $User $Text"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"Sorry, no $Path file found"
|
"Sorry, no memos saved yet"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
exit 0
|
exit 0
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user