{"id":16041,"date":"2011-01-01T00:01:00","date_gmt":"2011-01-01T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2011\/01\/01\/weekend-scripter-download-lyrics-for-your-favorite-song-with-powershell\/"},"modified":"2011-01-01T00:01:00","modified_gmt":"2011-01-01T00:01:00","slug":"weekend-scripter-download-lyrics-for-your-favorite-song-with-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-download-lyrics-for-your-favorite-song-with-powershell\/","title":{"rendered":"Weekend Scripter: Download Lyrics for Your Favorite Song with PowerShell"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><p><span style=\"font-size:10.0pt\"><strong>Summary:<\/strong> Learn how to use a Windows PowerShell function to download lyrics for your favorite songs.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><h2>Retrieving song lyrics with Windows PowerShell<\/h2>\n<p><span style=\"font-size:10.0pt\">Microsoft Scripting Guy Ed Wilson here. Well it is New Year&rsquo;s day in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Charlotte,_North_Carolina\">Charlotte<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/North_Carolina\">North Carolina<\/a>. This year, or perhaps I should say last year, the <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/tags\/scripting+wife\/\">Scripting Wife<\/a> and I did not do anything for New Year&rsquo;s Eve. I had spent a few days looking around, and found some pretty cool things going on down in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Charleston,_SC\">Charleston<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/South_carolina\">South Carolina<\/a> that looked promising. However, with my continuing ear problems, we decided that going to listen to a live band is not necessarily the best thing to do. What I really wanted to find was a Windows PowerShell New Year&rsquo;s Eve gathering. I mean we could arrange for a half dozen speakers and do all PowerShell all night. Now that is something to get excited about! It would be way cooler than the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Elvis_Presley\">Elvis<\/a> contest we went to a couple of years ago. <\/span><\/p>\n<p><p><span style=\"font-size:10.0pt\">Because we did not do anything last night, I am up bright and early and cooking a pot of steel cut Irish Oats. These dudes take nearly an hour to cook, but it is worth the extra trouble. I like to sprinkle them with fresh ground <a href=\"http:\/\/en.wikipedia.org\/wiki\/Cinnamon\">Cinnamon<\/a>. Anyway, while I wait for the oats to come to a boil, I decided to look around for a web service I could use to retrieve song lyrics for the songs I listen to on my <a href=\"http:\/\/en.wikipedia.org\/wiki\/Zune_HD\">Zune HD<\/a>. This is something I have wanted to do for quite some time, but I have always had more important things to do. <\/span><\/p>\n<p><span style=\"font-size:10.0pt\">That is the good thing about scripting on New Year&rsquo;s Day because one can pretty much spend ones time doing whatever one wishes to do. After all, it is New Year&rsquo;s Day. Speaking of Elvis, have you ever tried to figure out what he is talking about in some of his songs? Between the &ldquo;ooh ha ooh ha&rdquo; and the &ldquo;thank you, thank you very much&rdquo; lots of words transpire that are fairly unintelligible. That is the good thing about retrieving song lyrics; I can finally understand the song (in some cases that might not necessarily be such a good thing). The complete <b>Get-Lyrics<\/b> function appears here.<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlockScreenedHead\"><span style=\"font-size:10.0pt\"><strong>Get-Lyrics function<\/strong><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size:10.0pt\">F<span style=\"font-family: courier new,courier\">unction Get-Lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">{<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp; <\/span>&lt;#<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Synopsis<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function returns song lyrics when provided with the name of a song<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Description<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function uses a web service to retrieve song lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Example<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics -artist &#8220;John Denver&#8221; -song &#8220;Rocky Mountain High&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Returns the lyrics to John Denver&#8217;s song &#8220;Rocky Mountain High&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Example<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics -artist elvis -song &#8220;hound dog&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Returns the lyrics to Elvis Presley&#8217;s song Hound Dog<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Parameter artist<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>The artist parameter accepts an artist name as a string<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Parameter song<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>The song parameter accepts a song title as a string<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Inputs<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Outputs<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>[string[]]<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Notes<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>NAME:<span>&nbsp; <\/span>Get-Lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>AUTHOR: ed wilson, msft<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>LASTEDIT: 12\/21\/2010 17:47:31<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>KEYWORDS: Using the Internet, Web Services<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>HSG: 1\/1\/11<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Link<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Http:\/\/www.ScriptingGuys.com<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>#Requires -Version 2.0<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>#&gt;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>Param(<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp; <\/span>[string]$artist,<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp; <\/span>[string]$song )<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$URI = &#8220;http:\/\/lyrics.wikia.com\/server.php?wsdl&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$Proxy = New-WebServiceProxy -uri $URI -namespace WebServiceProxy<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$details = $Proxy.GetSong($artist,$song)<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>&#8220;Details&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$details.Lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlockScreened\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">} #end Get-Lyrics<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size:10.0pt\">Most of the <b>Get-Lyrics<\/b> function is taken up by the comment-based help. I used <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/09\/11\/automatically-add-comment-based-help-to-your-powershell-scripts.aspx\">my <b>Add-Help<\/b> function<\/a> to add most of the <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/2010\/01\/07\/hey-scripting-guy-january-7-2010.aspx\">help tags<\/a>, and it therefore only took me about five minutes to fill in the blanks. <\/span><\/p>\n<p><span style=\"font-size:10.0pt\">I have a written <a href=\"http:\/\/blogs.technet.com\/search\/SearchResults.aspx?q=add-help&amp;sections=7618\"><span style=\"color:black;text-decoration:none\">several Hey, Scripting Guy! posts that talk about how to add help<\/span><\/a> to Windows PowerShell scripts. Refer to them for more information about how to use this helpful (pun intended) scripting technique. <\/span><\/p>\n<p><span style=\"font-size:10.0pt\">The complete comment-based help for the <b>Get-Lyrics<\/b> function appears here.<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\">&lt;<span style=\"font-family: courier new,courier\">#<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Synopsis<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function returns song lyrics when provided with the name of a song<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Description<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function uses a web service to retrieve song lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Example<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics -artist &#8220;John Denver&#8221; -song &#8220;Rocky Mountain High&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Returns the lyrics to John Denver&#8217;s song &#8220;Rocky Mountain High&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Example<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics -artist elvis -song &#8220;hound dog&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Returns the lyrics to Elvis Presley&#8217;s song Hound Dog<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Parameter artist<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>The artist parameter accepts an artist name as a string<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Parameter song<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>The song parameter accepts a song title as a string<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Inputs<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>[string]<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Outputs<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>[string[]]<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Notes<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>NAME:<span>&nbsp; <\/span>Get-Lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>AUTHOR: ed wilson, msft<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>LASTEDIT: 12\/21\/2010 17:47:31<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>KEYWORDS: Using the Internet, Web Services<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>HSG: 1\/1\/11<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp; <\/span>.Link<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Http:\/\/www.ScriptingGuys.com<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>#Requires -Version 2.0<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>#&gt;<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size:10.0pt\">The cool thing about the help, is that it integrates with the Get-Help Windows PowerShell cmdlet. Therefore, I can use the following command to retrieve help information.<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span style=\"font-family: courier new,courier\">Get-Help Get-Lyrics<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<p><span style=\"font-size:10.0pt\">In addition to the general help information, I can retrieve only the examples of usage, or the complete help information. The commands to do this appear here.<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span style=\"font-family: courier new,courier\">Get-Help Get-Lyrics &ndash;examples<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">Get-Help Get-Lyrics &ndash;full<\/span><\/span><\/p>\n<p><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size:10.0pt\">An example of the default help information appears here.<\/span><\/p>\n<blockquote>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\">P<span style=\"font-family: courier new,courier\">S C:\\Users\\ed.NWTRADERS&gt; Get-Help get-lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">NAME<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">SYNOPSIS<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function returns song lyrics when provided with the name of a song<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">SYNTAX<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics [[-artist] &lt;String&gt;] [[-song] &lt;String&gt;] [&lt;CommonParameters&gt;]<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">DESCRIPTION<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>This function uses a web service to retrieve song lyrics<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">RELATED LINKS<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Http:\/\/www.ScriptingGuys.com<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>#Requires -Version 2.0<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size:10.0pt\"><span><span style=\"font-family: courier new,courier\">&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>Get-Lyrics -artist &#8220;John Denver&#8221; -song &#8220;Rocky Mountain High&#8221; <\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">REMARKS<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>To see the examples, type: &#8220;get-help Get-Lyrics -examples&#8221;.<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>For more information, type: &#8220;get-help Get-Lyrics -detailed&#8221;.<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;&nbsp;&nbsp; <\/span>For technical information, type: &#8220;get-help Get-Lyrics -full&#8221;.<\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">The portion of the function that performs the actual work is relative lean. It is seen here.<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">Param(<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp; <\/span>[string]$artist,<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp; <\/span>[string]$song )<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$URI = &#8220;http:\/\/lyrics.wikia.com\/server.php?wsdl&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$Proxy = New-WebServiceProxy -uri $URI -namespace WebServiceProxy<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$details = $Proxy.GetSong($artist,$song)<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>&#8220;Details&#8221;<\/span><\/span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\"><span>&nbsp;<\/span>$details.Lyrics<\/span><\/span><\/p>\n<p><span style=\"font-size: 10pt\"><span style=\"font-family: courier new,courier\">&nbsp;<\/span><\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-size:10.0pt\">I create two parameters for the function: the artist name and the song title. The <i>$URI<\/i> variable holds the path to the WSDL (Web Service Definition Language). The <b>New-WebServiceProxy<\/b> Windows PowerShell cmdlet accepts the path to the WSDL, and I store the returned object in the <i>$Proxy<\/i> variable. I then call the <b>getsong<\/b> method and pass it the artist and the song. The object that returns contains a lyrics property that holds the song&rsquo;s lyrics. The following figure shows how to use this function directly inside the Windows PowerShell ISE. I run the script one time to load the function into memory, and then I can call the function directly from the command pane. <\/span><\/p>\n<p><span style=\"font-size:10.0pt\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8802.WES-1-1-11-01.jpg\" border=\"0\" \/><\/span><\/p>\n<p><span style=\"font-size:10.0pt\"><\/span>&nbsp;<\/p>\n<p><span style=\"font-size:10.0pt\">Well, that is about it for today. I think I hear the Scripting Wife calling. She has been busy cooking black-eyed peas and who knows what else. After all, it is New Year&rsquo;s Day in Charlotte. <\/span><\/p>\n<p><span style=\"font-size:10.0pt\">I invite you to follow me on <a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to me at <a target=\"_blank\" href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a> or post them on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/span><\/p>\n<p><span style=\"font-size:10.0pt\">&nbsp;<\/span><\/p>\n<p><span style=\"font-size:10.0pt\"><strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/span><\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Learn how to use a Windows PowerShell function to download lyrics for your favorite songs. &nbsp; Retrieving song lyrics with Windows PowerShell Microsoft Scripting Guy Ed Wilson here. Well it is New Year&rsquo;s day in Charlotte, North Carolina. This year, or perhaps I should say last year, the Scripting Wife and I did [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[123,3,167,214,61,45,199],"class_list":["post-16041","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-multimedia","tag-scripting-guy","tag-using-the-internet","tag-web-services","tag-weekend-scripter","tag-windows-powershell","tag-zune-and-other-media-devices"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Learn how to use a Windows PowerShell function to download lyrics for your favorite songs. &nbsp; Retrieving song lyrics with Windows PowerShell Microsoft Scripting Guy Ed Wilson here. Well it is New Year&rsquo;s day in Charlotte, North Carolina. This year, or perhaps I should say last year, the Scripting Wife and I did [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=16041"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16041\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=16041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}