It took longer than I expected, but my latest course for TrainSignal is now available. PowerShell v3 Essentials is targeted for IT Pros with little to no PowerShell experience. This is the course that will get you up and running in short order. I developed the course so that an IT Pro could be effective with the PowerShell console, using many of the new features found in PowerShell 3.0. One of those features is the Invoke-WebRequest cmdlet. I thought I'd share a version of a demonstration I did for the course on using Invoke-WebRequest to browse the TrainSignal course catalog.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
In case you didn't know, all of TrainSignal's courses are now delivered online on a monthly subscription basis starting at $49/month. Their site has all the pricing information you need. But you can also start with a 3 day free trial. Oh, and lessons can be viewed offline as well. Anyway...using Invoke-WebRequest I can "scrape" the TrainSignal courseware page using PowerShell. Here's my sample script.
#requires -version 3.0 <# a version of a demo from my PowerShell 3 course https://www.trainsignal.com/course/209/powershell-v3-essentials Do NOT run this in the PowerShell ISE as there is a memory bug with Invoke-WebRequest #> $base = "http://trainsignal.com" $uri = "$base/Browse" $r = Invoke-WebRequest $uri <# look at links if you want $r.links[0..5] $r.links | select OuterText,href #> #let's get just courses $courses = $r.links | where {$_.href -match "^/Course"} #format course data $data = $courses | Select @{Name="Title";Expression={$_.OuterText.Split("`n")[0].Trim()}}, @{Name="Instructor";Expression={$_.OuterText.Split("`n")[1].Trim()}}, @{Name="Date";Expression={$_.OuterText.Split("`n")[2].Trim() -as [datetime]}}, @{Name="Link";Expression={"$base$($_.href)"}} #send the data to Out-Gridview $data | Out-GridView -Title "Trainsignal Courses: select one or more courses" -PassThru | Foreach { #open selected links in the browser start $_.link } #end of script
The script saves the results from Invoke-WebRequest to a variable. In looking through the raw html I learned how the links were formatted and discovered that I only wanted links that started with /Course. I also figured out that the link objects had instructor and course information that could be parsed out of the OuterText property so I reformat the data into something more object-like.
I did this so that I could push the results to Out-Gridview displaying the courses.
In PowerShell 3, Out-Gridview can pass objects back to the pipeline, so I can select a few courses that look interesting, click OK, and the links will open up in my web browser.
I had a lot of fun creating this course and hope you find it worth your investment. Let me know what you think. And if there is a course you'd like to see me create, especially PowerShell related, let me know that too.
2 thoughts on “Browse TrainSignal Courses with PowerShell”
Comments are closed.