Get cryptocurrencies price using PowerShell

Today’s script will not be directly connected with Microsoft stuff, but it will show you how to get cryptocurrencies price using PowerShell.

Cryptocurrencies every year become more popular and in my humble opinion will enter the mainstream very soon.
I thought it can be very handfull for cryptotraders who are interesting in PowerShell to have function which will get cryptocurrencies price.
Base on this script more experienced scripters can build script which will trade for them 🙂

How it works?

Function is very simple. It connects to API and gather a list of all available cryptocurrencies.
In next step, script is filtering all cryptos array to search for one provided by the user in the function.
Example of usage below:

Get-CryptoPrice -CryptoName Bitcoin
Function Get-CryptoPrice {
    [Parameter(Position=0, Mandatory = $true, HelpMessage="Cryptocurrency full name", ValueFromPipeline = $false)] 
        $AllCryptosArray = (Invoke-WebRequest -uri | ConvertFrom-Json
        $Exception = $_.Exception.Message
        Write-Error "Can not connect to API. Following error occured: $Exception"

    $Crypto = $AllCryptosArray | Where-Object Name -eq $CryptoName
    If($Crypto.Count -eq 0)
        Write-Output "There is no $CryptoName coin listed on!"
        $Crypto | Format-Table -AutoSize

I hope it will be usefull for some of you 😉

2 thoughts on “Get cryptocurrencies price using PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *