PowerShell/Scripts/list-earthquakes.ps1

21 lines
704 B
PowerShell
Raw Normal View History

2020-12-14 20:28:21 +01:00
#!/snap/bin/powershell
2020-12-29 15:14:21 +01:00
<#
.SYNTAX ./list-earthquakes.ps1
.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-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 {
2020-12-25 11:30:43 +01:00
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-14 20:28:21 +01:00
exit 1
}