mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-11 11:04:46 +02:00
Update list-earthquakes.ps1
This commit is contained in:
parent
efd57ea300
commit
eb098a1290
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists major earthquakes since 30 days
|
Lists major earthquakes
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script lists earthquakes with magnitude >= 6.0 for the last 30 days.
|
This PowerShell script lists major earthquakes with magnitude >= 6.0 for the last 30 days.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-earthquakes
|
PS> ./list-earthquakes
|
||||||
.LINK
|
.LINK
|
||||||
@ -11,15 +11,16 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$Format="csv" # csv, geojson, kml, text, xml
|
$Format="csv" # cap, csv, geojson, kml, kmlraw, quakeml, text, xml
|
||||||
$MinMagnitude=5.8
|
$MinMagnitude=5.8
|
||||||
$OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc
|
$OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc
|
||||||
|
|
||||||
function ListEarthquakes {
|
function ListEarthquakes {
|
||||||
write-progress "Loading data ..."
|
Write-Progress "Loading data from earthquake.usgs.gov..."
|
||||||
$Earthquakes = (Invoke-WebRequest -URI "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-CSV
|
$Quakes = (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 $Quakes) {
|
||||||
New-Object PSObject -Property @{ Mag=$Quake.mag; Depth="$($Quake.depth) km"; Location=$Quake.place; Time=$Quake.time }
|
[int]$Depth = $Quake.depth
|
||||||
|
New-Object PSObject -Property @{ Mag=$Quake.mag; Depth="$Depth km"; Location=$Quake.place; Time=$Quake.time }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,4 +31,3 @@ try {
|
|||||||
"⚠️ 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