PowerShell/Scripts/list-earthquakes.ps1

20 lines
701 B
PowerShell
Raw Normal View History

2021-04-21 19:53:52 +02:00
<#
2021-04-07 15:17:49 +02:00
.SYNTAX list-earthquakes.ps1
2021-03-22 20:10:18 +01:00
.DESCRIPTION lists earthquakes with magnitude >= 6.0 for the last 30 days
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2020-12-29 15:14:21 +01:00
#>
2020-12-14 20:28:21 +01:00
$Format="csv" # csv, geojson, kml, text, xml
$MinMagnitude=6.0
2020-12-14 20:36:44 +01:00
$OrderBy="time" # time, time-asc, magnitude, magnitude-asc
2020-12-14 20:28:21 +01:00
try {
2020-12-25 11:30:43 +01:00
write-progress "Querying earthquakes for the last 30 days ..."
2020-12-14 20:36:44 +01:00
(Invoke-WebRequest -Uri "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -UserAgent "curl" ).Content
2020-12-14 20:28:21 +01:00
exit 0
} catch {
2021-05-02 21:30:48 +02:00
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-14 20:28:21 +01:00
exit 1
}