PowerShell your world cup

June 17, 2013

Table of Contents

PowerShell This is something that is very exciting and if you are interested you should try it. I found the post and tried it. Here is a function and how you use them.

  • Go to the kimono website and sign up for an account(http: //www.kimonolabs.com/signup)

This will get you an APIKey. Click your name once after you have logged in and then select your account.

  • Copy the API key and paste it below in the script and enjoy!

The Functions

$global:APIkey = “YOUR-KEY-GOES-HERE-FROM-STEP-2”

 

Function Get-WorldCupPlayer ($Country) {

    If ($Country) {

        $TeamID = (Get-WorldCupTeam -Country $Country).id

        Invoke-WebRequest -Uri (“http://worldcup.kimonolabs.com/api/players?teamId=$($TeamID)&apikey=$($ApiKey)”) | ConvertFrom-Json

    } Else {

        Invoke-WebRequest -Uri “http://worldcup.kimonolabs.com/api/players?apikey=$($ApiKey)” | ConvertFrom-Json

    }

}

Function Get-WorldCupTeam ($Country, $TeamID) {

    If ($Country) {

        Invoke-WebRequest -Uri (“http://worldcup.kimonolabs.com/api/teams?name=$($Country)&apikey=$($ApiKey)”) | ConvertFrom-Json

    }

    If ($TeamID) {

        Invoke-WebRequest -Uri (“http://worldcup.kimonolabs.com/api/teams?id=$($TeamID)&apikey=$($ApiKey)”) | ConvertFrom-Json

    }

 

    If (!$country -and !$TeamID) {

        Invoke-WebRequest -Uri “http://worldcup.kimonolabs.com/api/teams?apikey=$($ApiKey)” | ConvertFrom-Json

    }

}

Function Get-WorldCupStat {

    Invoke-WebRequest -Uri (“http://worldcup.kimonolabs.com/api/teams?sort=goalsFor,-1&apikey=$($ApiKey)”) | ConvertFrom-Json

}

Bring on the World Cup Fun

#Display the best team in the World Cup

Get-WorldCupTeam -Country “England”

Get-WorldCupStat | Format-Table

Get-WorldCupPlayer | Format-Table

Get-WorldCupPlayer -Country “England” | Format-Table

#Who has scored the most goals in the Netherland team so far?

Get-WorldCupPlayer -Country “Netherlands” | Foreach { $_ | Where

{ $_.goals -gt 0 } | Select firstName, lastName, goals } | sort goals –

Descending

#View the Logo of the team who is going to win

$logo = (New-Object System.Net.WebClient).DownloadFile(((Get-WorldCupTeam -Country “England”).logo), ($env:TEMP + “Logo.png”))

Invoke-Item $env:TEMPLogo.png

Home

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March