mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-27 10:23:17 +01:00
27 lines
722 B
PowerShell
Executable File
27 lines
722 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
list-city-weather.ps1
|
|
.DESCRIPTION
|
|
List the current weather of cities world-wide (west to east)
|
|
.EXAMPLE
|
|
PS> .\list-city-weather.ps1
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
.NOTES
|
|
Author: Markus Fleschutz
|
|
License: CC0
|
|
#>
|
|
|
|
$Cities="Hawaii","Los Angeles","Mexico City","Miami","New York","Rio de Janeiro","Paris","London","Berlin","Cape Town","Dubai","Mumbai","Singapore","Hong Kong","Peking","Tokyo","Sydney"
|
|
|
|
try {
|
|
foreach($City in $Cities) {
|
|
$Line = (Invoke-WebRequest http://wttr.in/${City}?format="%c %l+%t+%p+%h+%P+%w +%S →+%s" -UserAgent "curl").Content
|
|
"$Line"
|
|
}
|
|
exit 0
|
|
} catch {
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|