mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 09:28:21 +02:00
Add list-earthquakes.ps1
This commit is contained in:
parent
53d44cc2dd
commit
02ee5672a7
@ -8,7 +8,7 @@
|
|||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz / License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$Format="csv" # csv, geojson, kml, text, xml
|
$Format="csv" # csv, geojson, kml, text, xml
|
||||||
@ -17,16 +17,17 @@ $OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc
|
|||||||
|
|
||||||
function ListEarthquakes {
|
function ListEarthquakes {
|
||||||
write-progress "Loading data ..."
|
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) {
|
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 {
|
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
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
f
|
Loading…
Reference in New Issue
Block a user