Add list-exchange-rates.ps1

This commit is contained in:
Markus Fleschutz 2021-08-03 17:01:09 +02:00
parent f6dd2dc878
commit 6c8cbf3c27
4 changed files with 62 additions and 1 deletions

View File

@ -106,6 +106,7 @@ list-memos.ps1, lists the memos at $HOME/Memos.csv
list-unused-files.ps1, lists unused files in a directory tree
list-cmdlets.ps1, lists the PowerShell cmdlets
list-earthquakes.ps1, lists earthquakes with magnitude >= 6.0 for the last 30 days
list-exchange-rates.ps1, lists the exchange rates for the given currency
list-modules.ps1, lists the PowerShell modules
list-mysql-tables.ps1, lists the MySQL server tables
list-network-shares.ps1, lists the network shares of the local computer

Can't render this file because it has a wrong number of fields in line 79.

View File

@ -202,6 +202,7 @@ Mega Collection of PowerShell Scripts
* [list-fritzbox-calls.ps1](Scripts/list-fritzbox-calls.ps1) - lists the FRITZ!Box calls
* [list-fritzbox-devices.ps1](Scripts/list-fritzbox-devices.ps1) - lists FRITZ!Box's known devices
* [list-earthquakes.ps1](Scripts/list-earthquakes.ps1) - lists earthquakes with magnitude >= 6.0 for the last 30 days
* [list-exchange-rates.ps1](Scripts/list-exchange-rates.ps1) - lists the exchange rates for the given currency
* [list-memos.ps1](Scripts/list-memos.ps1) - lists the memos at $HOME/Memos.csv
* [list-mysql-tables.ps1](Scripts/list-mysql-tables.ps1) - lists the MySQL server tables
* [list-news.ps1](Scripts/list-news.ps1) - lists the latest news

View File

@ -0,0 +1,59 @@
<#
.SYNOPSIS
list-exchange-rates.ps1 [<currency>]
.DESCRIPTION
Lists the exchange rates for the given currency (USD per default)
.EXAMPLE
PS> .\list-exchange-rates.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
License: CC0
#>
param([string]$currency = "USD")
function WriteBar { param([string]$Text, [float]$Value, [float]$Max)
$Num = $Value
if ($Num -gt $Max) { $Num = $Max }
$Num = ($Num * 70.0) / $Max
while ($Num -ge 1.0) {
write-host -noNewLine ""
$Num -= 1.0
}
if ($Num -ge 0.875) {
write-host -noNewLine ""
} elseif ($Num -ge 0.75) {
write-host -noNewLine ""
} elseif ($Num -ge 0.625) {
write-host -noNewLine ""
} elseif ($Num -ge 0.5) {
write-host -noNewLine ""
} elseif ($Num -ge 0.375) {
write-host -noNewLine ""
} elseif ($Num -ge 0.25) {
write-host -noNewLine ""
} elseif ($Num -ge 0.125) {
write-host -noNewLine ""
}
write-host " $Value $Text"
}
try {
" Exchange Rates Today for 1 $currency"
" =============================="
" Source: http://www.floatrates.com"
""
[xml]$ExchangeRates = (invoke-webRequest -uri "http://www.floatrates.com/daily/$($currency).xml").Content
foreach($Row in $ExchangeRates.channel.item) {
[string]$Name = $Row.targetName
[float]$Value = $Row.exchangeRate
WriteBar $Name $Value 10.0
}
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}

View File

@ -4,7 +4,7 @@
.DESCRIPTION
Lists the TIOBE index of top programming languages
.EXAMPLE
PS> .\list-tiobe-index.ps1.ps1
PS> .\list-tiobe-index.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES