Start-Website

 

Start-Website

Start a website with which ever browser you want it to start with PowerShell

By Michael J. Thomas


The other day I had built a function that could start a website with which ever browser I decided I wanted it to open with. This comes in handy when testing websites that you build or just with opening sites that are better compatible with one browser over the other. Here is this cool function. 




<#
.Synopsis
   Start-Website with a browser selection option. 
.DESCRIPTION
   Start-Website function is used to select which web browser you want to open a website with. 
.EXAMPLE
   Start-Website -Site PowerShellWeekly.com -Browser Edge

.EXAMPLE
   Start-Website PowerShellWeekly.com Edge
   Start-Website ProgrammingEveryDay.com Edge
   
.EXAMPLE
   Start-Website -Site ThomasITServices.com -Browser Chrome

.EXAMPLE
  Start-Website -Site https://www.affauto.com -Browser IE

#>

function Start-Website
{
[CmdletBinding()]
param (
[String]$Site,
[ValidateSet('Chrome','Edge','IE')] $Browser
)

Switch ($Browser)
{
"Chrome"{ Start-Process "chrome.exe" $Site; Break; }
"Edge"{ Start-Process microsoft-edge:$Site; Break; }
"IE"{ $ie = New-Object -ComObject InternetExplorer.Application; $ie.Navigate($Site); $ie.Visible = $true; Break; }
}
}


Comments

Popular posts from this blog

Add-RemoteDesktopUsers

Invoke-Reprofile

Keep All Network Connections Private ( Set-PrivateNetwork )