Skip to content

Commit 02ee567

Browse files
committed
Add list-earthquakes.ps1
1 parent 53d44cc commit 02ee567

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Scripts/list-earthquakes.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
.LINK
99
https://github.com/fleschutz/PowerShell
1010
.NOTES
11-
Author: Markus Fleschutz / License: CC0
11+
Author: Markus Fleschutz | License: CC0
1212
#>
1313

1414
$Format="csv" # csv, geojson, kml, text, xml
@@ -17,16 +17,17 @@ $OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc
1717

1818
function ListEarthquakes {
1919
write-progress "Loading data ..."
20-
$Earthquakes = (invoke-webRequest -uri "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-CSV
20+
$Earthquakes = (Invoke-WebRequest -URI "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-CSV
2121
foreach ($Quake in $Earthquakes) {
22-
new-object PSObject -Property @{ Mag=$Quake.mag; Depth=$Quake.depth; Location=$Quake.place; Time=$Quake.time }
22+
New-Object PSObject -Property @{ Mag=$Quake.mag; Depth="$($Quake.depth) km"; Location=$Quake.place; Time=$Quake.time }
2323
}
2424
}
2525

2626
try {
27-
ListEarthquakes | format-table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=6},Time
27+
ListEarthquakes | Format-Table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=12},Time
2828
exit 0 # success
2929
} catch {
3030
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
3131
exit 1
3232
}
33+
f

0 commit comments

Comments
 (0)