Public/Start-Chrome.ps1

Function Start-Chrome {
    <#
    .Synopsis
        Starts Google Chrome
    .Description
        Starts Google Chrome
    .Example
        Start-Chrome -incognito
        Starts Google Chrome in Incognito mode
    .Parameter incognito
        Starts Google Chrome in Incognito mode
    .Inputs
        None
    .Outputs
        None
    .Notes
        NAME: Start-Chrome
        AUTHOR: Casper Stekelenburg
        LASTEDIT: 05/06/2016 20:42:50
        KEYWORDS: Google,Chrome,Browser
    .LINK
        about_functions_advanced
    .LINK
        about_CommonParameters
    #>

    [CmdletBinding(
        ConfirmImpact = "Medium"
    )]
    Param (
        [switch]$incognito
    )

    $RegKey = "HKLM:\SOFTWARE\Clients\StartMenuInternet\Google Chrome\shell\open\command"
    If ((Test-Path $RegKey)) {
        $ChromeInstallPath = Get-ItemProperty -Path "HKLM:\SOFTWARE\Clients\StartMenuInternet\Google Chrome\shell\open\command"
        $ChromeInstallPath = $ChromeInstallPath.'(default)'
        $path = $ChromeInstallPath.Split("\")
        $path[0] = $path[0] + "\"
        $path[0] = $path[0].Split('"')
        $path[0] = $path[0].TrimStart()
        $path[1] = $path[1] + "\"
        $path[2] = $path[2] + "\"
        $path[3] = $path[3] + "\"
        $path[4] = $path[4] + "\"
        $path = $path[0] + $path[1] + $path[2] + $path[3] + $path[4]
        $path = $path.TrimStart()
        Write-Verbose "Testing Google Chrome installation in $path"
        If ((Test-Path $path\chrome.exe)) {
            If (!($incognito)) {
                Write-Verbose "chrome.exe found, starting..."
                Start-Process $path\chrome.exe
            }
            If ($incognito) {
                $args = "--incognito"
                Write-Verbose "chrome.exe found, starting..."
                Start-Process $path\chrome.exe -ArgumentList "--incognito"
            }
        }
    }
}