mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
Add list-exchange-rates.ps1
This commit is contained in:
parent
f6dd2dc878
commit
6c8cbf3c27
@ -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.
|
@ -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
|
||||
|
59
Scripts/list-exchange-rates.ps1
Normal file
59
Scripts/list-exchange-rates.ps1
Normal 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
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user