{"id":76051,"date":"2015-12-31T00:01:00","date_gmt":"2015-12-31T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/12\/31\/sounds-of-the-holidayspart-2\/"},"modified":"2022-06-16T09:59:10","modified_gmt":"2022-06-16T16:59:10","slug":"sounds-of-the-holidayspart-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/sounds-of-the-holidayspart-2\/","title":{"rendered":"Sounds of the Holidays\u2013Part 2"},"content":{"rendered":"<p><strong>Summary<\/strong>: MVP, Thomas Rayner, continues to inspire holiday spirit by using PowerShell to trigger multimedia.<\/p>\n<p>Yesterday in <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/sounds-of-the-holidayspart-1\/\" target=\"_blank\" rel=\"noopener\">Sounds of the Holidays\u2013Part 1<\/a>, I tried to inspire my coworker, Matthew, with some cool holiday messages. Unfortunately, Matthew is still being a Grinch and I need to step up my game. Instead of some spoken messages from \u201cEbenezer Script,\u201d I\u2019m going to play him some holiday music every time he signs in to his workstation.<\/p>\n<p>I\u2019m a fan of the Charlie Brown holiday jazz album by the Vince Guaraldi Trio, and they\u2019ve been kind enough to upload some of their music to YouTube. I\u2019ve chosen this great piece to play for Matthew: <a href=\"https:\/\/www.youtube.com\/watch?v=YvI_FNrczzQ%20\">Christmas Time Is Here<\/a>.<\/p>\n<p>My script for this is pretty simple. First, I\u2019m going to use a couple of variables to define where the startup folder is on Matthew\u2019s computer and the URL to this YouTube video. Be advised that anything in the startup folder is executed every time a user signs in to the workstation\u2014so be careful with what you put in here.<\/p>\n<p style=\"margin-left:30px\">\n  $Computer = &#8216;\\\\Matthew-Computer\\c$\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp&#8217;\n<\/p>\n<p style=\"margin-left:30px\">\n  $MusicURL = &#8216;https:\/\/www.youtube.com\/watch?v=YvI_FNrczzQ&#8217;\u00a0\n<\/p>\n<p>I know how to launch Internet Explorer to a specific page. It\u2019s as easy as:<\/p>\n<p style=\"margin-left:30px\">\n  iexplore.exe http:\/\/workingsysadmin.com\n<\/p>\n<p>However, I want to capture that line in a variable without executing it, so this is what I\u2019ll use:\u00a0<\/p>\n<p style=\"margin-left:30px\">\n  $PlayMusic = @&#8221;\n<\/p>\n<p style=\"margin-left:30px\">\n  Start-Process -WindowStyle Minimized &#8216;iexplore.exe&#8217; $MusicURL\n<\/p>\n<p style=\"margin-left:30px\">\n  &#8220;@\u00a0\n<\/p>\n<p>By using the <strong>@\u201d <some text> \u201c@<\/strong> syntax to create a here-string, I\u2019ve defined a block of text composed of the command to launch Internet Explorer at the URL of my YouTube video. I\u2019ve decided to launch Internet Explorer as minimized. Now all I need to do is write that command to a file in Matthew\u2019s startup folder:<\/p>\n<p style=\"margin-left:30px\">\n  $StartupScript = New-Item -ItemType File -Path &#8220;$Computer\\PlayMe.ps1&#8221;\n<\/p>\n<p style=\"margin-left:30px\">\n  Set-Content -Value $PlayMusic -Path $StartupScript.FullName\u00a0\n<\/p>\n<p style=\"margin-left:30px\">\n  This is the full script.\n<\/p>\n<p style=\"margin-left:30px\">\n  $Computer = &#8216;\\\\Matthew-Computer\\c$\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp&#8217;\n<\/p>\n<p style=\"margin-left:30px\">\n  $MusicURL = &#8216;https:\/\/www.youtube.com\/watch?v=YvI_FNrczzQ&#8217;\n<\/p>\n<p style=\"margin-left:30px\">\n  $PlayMusic = @&#8221;\n<\/p>\n<p style=\"margin-left:30px\">\n  Start-Process -WindowStyle Minimized &#8216;iexplore.exe&#8217; $MusicURL\n<\/p>\n<p style=\"margin-left:30px\">\n  &#8220;@\n<\/p>\n<p style=\"margin-left:30px\">\n  $StartupScript = New-Item -ItemType File -Path &#8220;$Computer\\PlayMe.ps1&#8221;\n<\/p>\n<p style=\"margin-left:30px\">\n  Set-Content -Value $PlayMusic -Path $StartupScript.FullName\u00a0\n<\/p>\n<p>It\u2019s that easy! Now Matthew will be able to enjoy some nice holiday music every time he signs in to his computer. If that doesn\u2019t raise his holiday spirits, nothing will!<\/p>\n<p>~Thomas<\/p>\n<p>Thanks again, Thomas! Always nice to have a little fun with PowerShell!<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\" rel=\"noopener\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\" rel=\"noopener\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\" rel=\"noopener\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\" rel=\"noopener\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: MVP, Thomas Rayner, continues to inspire holiday spirit by using PowerShell to trigger multimedia. Yesterday in Sounds of the Holidays\u2013Part 1, I tried to inspire my coworker, Matthew, with some cool holiday messages. Unfortunately, Matthew is still being a Grinch and I need to step up my game. Instead of some spoken messages from [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,652,45],"class_list":["post-76051","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-thomas-rayner","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: MVP, Thomas Rayner, continues to inspire holiday spirit by using PowerShell to trigger multimedia. Yesterday in Sounds of the Holidays\u2013Part 1, I tried to inspire my coworker, Matthew, with some cool holiday messages. Unfortunately, Matthew is still being a Grinch and I need to step up my game. Instead of some spoken messages from [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76051","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\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=76051"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/76051\/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=76051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=76051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=76051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}