mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-26 14:26:10 +01:00
Add list-earthquakes.ps1
This commit is contained in:
parent
53d44cc2dd
commit
02ee5672a7
@ -8,7 +8,7 @@
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
$Format="csv" # csv, geojson, kml, text, xml
|
||||
@ -17,16 +17,17 @@ $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" -useBasicParsing).Content | ConvertFrom-CSV
|
||||
$Earthquakes = (Invoke-WebRequest -URI "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-CSV
|
||||
foreach ($Quake in $Earthquakes) {
|
||||
new-object PSObject -Property @{ Mag=$Quake.mag; Depth=$Quake.depth; Location=$Quake.place; Time=$Quake.time }
|
||||
New-Object PSObject -Property @{ Mag=$Quake.mag; Depth="$($Quake.depth) km"; Location=$Quake.place; Time=$Quake.time }
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ListEarthquakes | format-table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=6},Time
|
||||
ListEarthquakes | Format-Table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=12},Time
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
f
|
Loading…
Reference in New Issue
Block a user