Search code examples
powershellmultiple-browsers

Open multiple browsers in incognito / private mode via Powershell


I want to open a single URL with IE, CH and FF, using incognito/private mode.

I can open the url with the 3 browsers using this Powershell script:

Param(
[string] $url
)


[System.Diagnostics.Process]::Start("chrome.exe", $url)      
[System.Diagnostics.Process]::Start("firefox.exe",$url )


$IE=new-object -com internetexplorer.application
$IE.navigate2($url)
$IE.visible=$true

how can I open the browsers in incognito mode?


Solution

  • chrome.exe takes an --incognito command line option:

    [System.Diagnostics.Process]::Start("chrome.exe","--incognito $url")
    

    Similarly, firefox.exe takes a -private-window command line option:

    [System.Diagnostics.Process]::Start("firefox.exe","-private-window $url")
    

    And as noted by @TToni in the comments, for iexplore.exe the equivalent is -private:

    [System.Diagnostics.Process]::Start("iexplore.exe","$url -private")
    

    The InternetExplorer.Application com object doesn't support InPrivate browsing AFAIK