0

Get-NextTrain

I was getting rather fed up with using National Rails IOS App to get the latest train times as it kept crashing on me so i wrote a small PowerShell function that will do the work for me :-)

This uses the 3 character code for Manchester Piccadilly and Macclesfield and then creates a new instance of Internet explorer with the results – I did look to make use of Invoke-WebRequest but felt that this was the “quicker and dirtier” solution

function Get-NextTrain {

    $from = “MAN”

    $to = “MAC”

    $date = Get-date -Format ddMMyy

    $time = Get-date -Format HHmm

    $url = “http://ojp.nationalrail.co.uk/service/timesandfares/$from/$to/$date/$time/dep/”

   start iexplore $url

   }

I am currently trying to create another that will accept a Full Station name input and then switch it to the short 3 character code for each Station name. Hopefully by the end of the week :-)

Leave a Reply