0
votes

I'm automating testing a site under different users with windows authentication. I've quickly discovered that internet explorer "Intranet" settings are specific per user.

Is there a way to either:

  1. Force open a website under "intranet" mode using powershell
  2. Change Internet Explorer settings for all users (so that each time that I open internet explorer with a new user it does not lose my settings).

    $username = "domain\user" $password = "password" $secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr

    Start-Process "C:\Program Files\Internet Explorer\iexplore.exe" http://portal.site.local/test -Credential $cred

3

3 Answers

0
votes

Only Tested with IE 8 on Windows 7:

> Make all users read security settings from HKLM instead of HKCU:

PS> Set-HKLM-Only # (-disable)

> Make "google.com" an intranet site:

PS> Set-Zone -URL "google.com" -ZoneLevel 1 # (-1 to remove from list)

Function Set-HKLM-Only {
param(
 [switch]$disable
)
    if($disable) {
        Remove-ItemProperty -Path "$regIEpolSettings" -Name "Security_HKLM_Only" -Force
    } else {
        New-ItemProperty -Path "$regIEpolSettings" -Name "Security_HKLM_Only" -Value 1 -PropertyType dword -Force
    }
}

Function Set-Zone {
param(
 [parameter(mandatory=$true)]
 [string] $URL,
 [ValidateRange(-1,4)] 
 [parameter(
    mandatory=$true,
    HelpMessage="-1 = Remove from zonelist , 0 = This Machine , 1 = Local Intranet , 2 = Trusted Sites , 3 = Internet , 4 = Restricted Sites"
 )]
 [int] $ZoneLevel
)
    if($ZoneLevel -lt 0) {
        Remove-Item -Path "$regIEpolSettings\ZoneMap\Domains\$URL" -Force
    } else {
        New-Item -Path "$regIEpolSettings\ZoneMap\Domains\$URL" -Force
        New-ItemProperty -Path "$regIEpolSettings\ZoneMap\Domains\$URL" -Name '*' -Value $ZoneLevel -PropertyType dword -Force
    }
}

New-Variable -Scope Script -Name regIEpolSettings -Value "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" -Force

/M

0
votes

Found a way, but would still be interested in how to do it via PowerShell:

Open Group Policy Editor, go to:
 User Configuration > Administrative Templates > Windows Components
 > Internet Explorer > Internet Control Panel > Security Page
 Open "Site to Zone Assignment list"
 Set Enabled, Click "Show" and enter:
 Value Name: your site (ex: portal.site.local)
 Value: 1
0
votes

You could try setting a powershell script which changes IE's default home page in the registry to run as a scheduled event. This should do the job in Windows 7:

    set-ItemProperty -name 'Start Page' -path 'HKCU:\Software\Microsoft\Internet Explorer\Main' -Value www.yoursite.com