Open Web Page

by Jun 29, 2015

To quickly open a new web page in the Internet Explorer, you could define a new function called Show-WebPage like this:

#requires -Version 2

function Show-WebPage
{
    param
    (
        [Parameter(Mandatory = $true, HelpMessage = 'URL to open')]
        $URL
    )

    Start-Process -FilePath iexplore.exe -ArgumentList $URL
} 

When you run this script and then enter Show-WebPage, the command asks you for a URL to open. You can also submit the URL as argument to Show-WebPage.

Note how the function uses Start-Process to launch the browser of your choice. If you changed the line to…

Start-Process -FilePath $URL

…then the URL would open in your default browser instead.

Twitter This Tip! ReTweet this Tip!