mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 16:03:22 +01:00
Improve list-earthquakes.ps1
This commit is contained in:
parent
4c287a5944
commit
6230f7ccc2
@ -6,12 +6,19 @@
|
||||
#>
|
||||
|
||||
$Format="csv" # csv, geojson, kml, text, xml
|
||||
$MinMagnitude=6.0
|
||||
$OrderBy="time" # time, time-asc, magnitude, magnitude-asc
|
||||
$MinMagnitude=5.8
|
||||
$OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc
|
||||
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
write-progress "Querying earthquakes for the last 30 days ..."
|
||||
(Invoke-WebRequest -Uri "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -UserAgent "curl" ).Content
|
||||
ListEarthquakes | format-table -autoSize -property Magnitude,Depth,Place,Time
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user