Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Friday Fun Quote of the Day

Posted on November 5, 2010March 28, 2011

For this week's Friday Fun post, I have another idea on how to brighten your PowerShell console. The concept of a message of the day or quote of the day in computing goes way back to the dark ages (ie before PowerShell). I thought it might be fun to see what we could do with this idea.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

There are a number of online sources for things like a quote of the day. One that I came across that I liked was BrainyQuote.com. One think I especially liked was an RSS feed for their quote of the day. Here's why: I can use PowerShell to download data from the RSS feed and present it in PowerShell.

[cc lang="PowerShell"]
Function Get-QOTD {

[cmdletBinding()]

Param()

Write-Verbose "Starting Get-QOTD"
#create the webclient object
$webclient = New-Object System.Net.WebClient

#define the url to connect to
$url="http://feeds.feedburner.com/brainyquote/QUOTEBR"

Write-Verbose "Connecting to $url"
Try
{
#retrieve the url and save results to an XML document
[xml]$data =$webclient.downloadstring($url)
#parse out the XML document to get the first item which
#will be the most recent quote
$quote=$data.rss.channel.item[0]
}
Catch
{
$msg="There was an error connecting to $url"
$msg+=$_.Exception.Message
Write-Warning $msg
}

if ($quote)
{
Write-Verbose $quote.OrigLink
"{0} - {1}" -f $quote.Description,$quote.Title
}
else
{
Write-Warning "Failed to get data from $url"
}

Write-Verbose "Ending Get-QOTD"

} #end function
[/cc]

My function uses the .NET WebClient to download the RSS feed. This comes down as string of XML data, but by casting the object as [xml], I get an XML document. With this, all I need to do is grab the relevant parts and write the resulting string to the pipeline. The quote itself is the description and the attribution source is the title.

I added this function to my profile. At the end of the profile, I get the quote of the day and display it.
[cc lang="PowerShell"]
$q=get-qotd
write-host "$q`n" -foregroundcolor Yellow
[/cc]

Here's the result when I start a new PowerShell session.

Download Get-QOTD and try it out.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

6 thoughts on “Friday Fun Quote of the Day”

  1. Pingback: Tweets that mention Friday Fun Quote of the Day | The Lonely Administrator -- Topsy.com
  2. JV says:
    November 5, 2010 at 11:32 am

    Jeff – file is not posted in good format for download. no linefeeds.

    1. Jeffery Hicks says:
      November 5, 2010 at 12:40 pm

      The only place I see it is in the disclaimer which you can delete anyway. Or is the whole download messed up, in which case what browser are you using?

  3. Sarah Dutkiewicz says:
    November 5, 2010 at 9:45 pm

    Ooh! What a cool idea!

    I’ll be able to start my PowerShell sessions with some sort of humorous anecdote or a clip from any of my favorite RSS feeds. I like it!

    I like seeing how you’re working with an RSS feed in PowerShell – so much simpler than if I had written it in C#. Thanks for posting this!

  4. Ian Manning says:
    November 15, 2010 at 8:50 am

    Love this sort of silly – now just need to find a practical use for it! 😉

    1. Jeffery Hicks says:
      November 15, 2010 at 12:12 pm

      The practical use is pulling information from an RSS feed. This is a silly quote of the day. But you could pull any information provided via an RSS feed.

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d