57 lines
1.8 KiB
PowerShell
57 lines
1.8 KiB
PowerShell
Get-Content .env | ForEach-Object {
|
|
if ($_ -match "^\s*([^#][^=]+)=(.*)$") {
|
|
$name = $matches[1].Trim()
|
|
$value = $matches[2].Trim()
|
|
|
|
[System.Environment]::SetEnvironmentVariable($name, $value)
|
|
}
|
|
}
|
|
|
|
$apiKey = $env:API_KEY
|
|
$startDate = "2026-01-01"
|
|
$endDate = "2026-01-01"
|
|
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "https://api.nasa.gov/neo/rest/v1/feed?start_date=$($startDate)&end_date=$($endDate)&api_key=$($apiKey)" -ResponseHeadersVariable headers
|
|
#$response = Invoke-WebRequest -Uri "https://api.nasa.gov/neo/rest/v1/feed?start_date=$($startDate)&end_date=$($endDate)&api_key=$($apiKey)"
|
|
|
|
#$response | ConvertTo-Json -Depth 10
|
|
$limit = $headers["X-RateLimit-Limit"]
|
|
$remaining = $headers["X-RateLimit-Remaining"]
|
|
|
|
Write-Host "-------------"
|
|
Write-Host "Rate Limit: $limit"
|
|
Write-Host "Remaining : $remaining"
|
|
Write-Host "-------------"
|
|
}
|
|
catch {
|
|
Write-Host "Fehler: $($_.Exception.Message)"
|
|
}
|
|
|
|
|
|
|
|
|
|
#$response | ConvertTo-Json -Depth 10 | Out-File ".\NeoFeed.json"
|
|
|
|
$limit = 0
|
|
|
|
$response.near_earth_objects.PSObject.Properties | ForEach-Object {
|
|
$date = $_.Name
|
|
$asteroids = $_.Value
|
|
|
|
Write-Host "Datum: $date"
|
|
Write-Host "-------------------"
|
|
|
|
foreach ($asteroid in $asteroids) {
|
|
if($asteroid.is_potentially_hazardous_asteroid){
|
|
Write-Host "| Name: $($asteroid.name) --- Hazardous: $($asteroid.is_potentially_hazardous_asteroid)" -ForegroundColor Red
|
|
}else {
|
|
Write-Host "| Name: $($asteroid.name) --- Hazardous: $($asteroid.is_potentially_hazardous_asteroid)" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "| Miss-Distance(in KM): $($asteroid.close_approach_data.miss_distance.kilometers)"
|
|
Write-Host "---------------------"
|
|
|
|
}
|
|
}
|