{"id":17648,"date":"2007-06-26T11:52:48","date_gmt":"2007-06-26T19:52:48","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17648"},"modified":"2019-05-16T11:54:04","modified_gmt":"2019-05-16T19:54:04","slug":"surfing-the-web-the-powershell-way","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/surfing-the-web-the-powershell-way\/","title":{"rendered":"Surfing the Web the PowerShell Way"},"content":{"rendered":"<p>I spend a lot of my time in the command line (surprised?). That said, I also spend a lot of time surfing the web. Here is a script that I wrote that lets me surf the web from PowerShell:\nUrlTemplateMap = @{\n&#8220;bs&#8221; = &#8220;http:\/\/blogsearch.google.com\/blogsearch?hl=en&#038;q={0}&#038;ie=UTF-8&#038;scoring=d&#8221;\n&#8220;dr&#8221; = &#8220;http:\/\/drudgereport.com&#8221;\n&#8220;gtr&#8221; = &#8220;http:\/\/www.google.com\/language_tools?hl=en&#8221; # GOOGLE TRANSLATE\n&#8220;verb&#8221; = &#8220;http:\/\/msdn2.microsoft.com\/en-us\/library\/ms714428.aspx&#8221;\n&#8220;v&#8221; = &#8220;http:\/\/msdn2.microsoft.com\/en-us\/library\/ms714428.aspx&#8221;\n&#8220;ps&#8221; = &#8220;http:\/\/blogs.msdn.com\/powershell\/default.aspx&#8221;\n}\n$Script:OutIE = $Null\nfunction Out-IE ($url, [Switch]$Reuse)\n{\nif ($Script:OutIE -eq $null -OR $Script:OutIE.Application -eq $null -OR !($Reuse))\n{\n$Script:OutIE = New-Object -Com InternetExplorer.Application\n}\nif ((!$url) -OR ($url -eq &#8220;?&#8221;) -OR ($url -eq &#8220;-?&#8221;))\n{\n$urlTemplateMap.GetEnumerator() |Sort Name |Format-Table @{Expression={$_.Name};Label=&#8221;Name&#8221;;Width=10},Value\nreturn\n}<\/p>\n<p>$navOpenInBackGroundTab = 0\nforeach ($u in @($url))\n{\n$templateUrl = $u\n$MappedUrl = $UrlTemplateMap.$u\nif ($MappedUrl)\n{\n$templateUrl = $MappedUrl\n}<\/p>\n<p># Use the Template and $args to generage the final URL\n$realUrl = $templateUrl -f $args\n$Script:OutIE.Navigate2($realUrl, $navOpenInBackGroundTab)\n$navOpenInBackGroundTab = 0x1000\n}\n$Script:OutIE.visible=1\n}\nSet-Alias oie Out-IE\nThis allows me a quick and easy way to navigate to my favorite URLs (I&#8217;ve included a subset of the ones I use). I put this into my profile file and then whenever I want to I can just type something like:\nPS> Oie v,gtr,dr \nAnd it will bring up IE (this is coded to Version 7 of IE) with 3 tabs for the corresponding URLS. This can also use parameterized URLS. For instance, I use google&#8217;s blogsearch which takes a parameter for the search term. To search blogs for PowerShell I do this:\nPS> Oie bs Powershell \nThis brings up a new window with all the blogs that have PowerShell in them. If I want to reuse an IE window, I use the \u2013REUSE flag.\nPS> Oie bs WINRM -reuse \nEnjoy!\nJeffrey Snover [MSFT]\nWindows Management Partner Architect\nVisit the Windows PowerShell Team blog at: http:\/\/blogs.msdn.com\/PowerShell\nVisit the Windows PowerShell ScriptCenter at: http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spend a lot of my time in the command line (surprised?). That said, I also spend a lot of time surfing the web. Here is a script that I wrote that lets me surf the web from PowerShell: UrlTemplateMap = @{ &#8220;bs&#8221; = &#8220;http:\/\/blogsearch.google.com\/blogsearch?hl=en&#038;q={0}&#038;ie=UTF-8&#038;scoring=d&#8221; &#8220;dr&#8221; = &#8220;http:\/\/drudgereport.com&#8221; &#8220;gtr&#8221; = &#8220;http:\/\/www.google.com\/language_tools?hl=en&#8221; # GOOGLE TRANSLATE &#8220;verb&#8221; [&hellip;]<\/p>\n","protected":false},"author":685,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17648","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>I spend a lot of my time in the command line (surprised?). That said, I also spend a lot of time surfing the web. Here is a script that I wrote that lets me surf the web from PowerShell: UrlTemplateMap = @{ &#8220;bs&#8221; = &#8220;http:\/\/blogsearch.google.com\/blogsearch?hl=en&#038;q={0}&#038;ie=UTF-8&#038;scoring=d&#8221; &#8220;dr&#8221; = &#8220;http:\/\/drudgereport.com&#8221; &#8220;gtr&#8221; = &#8220;http:\/\/www.google.com\/language_tools?hl=en&#8221; # GOOGLE TRANSLATE &#8220;verb&#8221; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/685"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17648"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17648\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}