PowerShell/Scripts/earthquakes.ps1

21 lines
671 B
PowerShell
Raw Normal View History

2020-12-14 20:28:21 +01:00
#!/snap/bin/powershell
# Syntax: ./earthquakes.ps1
# Description: prints the stronger earthquakes for the last 30 days
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$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 {
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 {
Write-Error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}