From 02ee5672a789d6e952c7de9c6f5eeed0846c5506 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 5 Sep 2022 20:21:23 +0200 Subject: [PATCH] Add list-earthquakes.ps1 --- Scripts/list-earthquakes.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/list-earthquakes.ps1 b/Scripts/list-earthquakes.ps1 index 3ce1947b..55cf0bd1 100755 --- a/Scripts/list-earthquakes.ps1 +++ b/Scripts/list-earthquakes.ps1 @@ -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 \ No newline at end of file