Skip to main content

Modify the Internet Explorer Compatibility List with PowerShell

Here is a good, real world question.  While examining the Group Policies settings for Internet Explorer in class.  The question came about as to whether or not the list can be modified in Group Policy by using PowerShell.  Well, yes you can.

The first thing is to determine what registry key we need to modify.  For the Compatibility list, the key is:
“HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList”

To utilize PowerShell for this task, we first need to add the Group Policy Module.
Import-Module GroupPolicy

Next, to add the website names www.abc.com to the GPO named IE Settings, type:
Set-GPRegistryValue –Name “IE Settings” –Key “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList” –ValueName “www.abc.com” –Type String –Value “www.abc.com”

Opening the GPO in the Group Policy Management Editor and manually entering the web site would be faster for a single site.  But what if you have a whole list?  That is where we need to turn to a PowerShell script.

The PowerShell code below will allow you to populate the contents of a text file in the Internet Explorer 7 Compatibility list in the GPO of your choice.  This will remove any entries already in the GPO.  Each time it is ran, it purges the compatibility list and recreates it.  For that reason, use the text file as your master list for websites that need to be ran in compatibility mode.

To use this code, copy and paste it into your PowerShell ISE.  Change the file location for the text file and the name of the GPO and run it.

<#===========================================================
Script Name: ManageCompatabilityList.ps1
Version: 1.0
Author: Jason A. Yoder, MCT

Website: www.MCTExpert.com
Blog: www.MCTExpert.BlogSpot.com


Script Purpose:
This script will add websites to the Internet Explorer 7
Compatibility List in a Group Policy.  The website address
will come from a text file.  The text file will completely
manage what is contained in the Compatibility list GPO. If
a website is removed from the text file, or is not in the
it will also be removed from the GPO.

Requirements:
This script has only been tested on a Windows Server 2008 R2
domain controller.



Revision History:
1.0
Created: January 28, 2011
Status: Completed
===========================================================#>



# ===========================================================
# Global Variables



$Website_List = "E:\Compatibility List\Websites.txt"
# file and location of the text file holding the list of
# websites that need to be included in the Compatibility
# list of the GPO.



$GPOName = "IE Settings"
# This is the name of the Group Policy that contains the
# Compatibility List to be modified.



$ListKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList"
# The registry key to be modified. 


# == End of Global Variables ================================


# ===========================================================
# Main Code:



Import-Module GroupPolicy
# Imports the GroupPolicy cmdlets for PowerShell into this
# session.



$ErrorActionPreference = "SilentlyContinue"
# Should the Compatibility list inside the GPO be not
# configured, an error would be generated.  This allows
# the script to continue execution.



# Remove the current contents of the Compatibility List.
Get-GPRegistryValue -Name $GPOName -Key $ListKey | `
Remove-GPRegistryValue -Name $GPOName -Key $ListKey

# Load the list of websites into memory.
$Websites = Get-Content $Website_List


# Add each of the websites to the GPO
For ($i = 0; $i -le $Websites.count-1; $i++)
    {
    Set-GPRegistryValue -Name $GPOName `
    -Key $ListKey -ValueName $Websites[$i] `
    -Type String -Value $Websites[$i]
    }
   
   
$ErrorActionPreference = "Stop"
#Reset the error action mode of PowerShell.


# == End of Main Code =======================================

Comments

Popular posts from this blog

How to list all the AD LDS instances on a server

AD LDS allows you to provide directory services to applications that are free of the confines of Active Directory.  To list all the AD LDS instances on a server, follow this procedure: Log into the server in question Open a command prompt. Type dsdbutil and press Enter Type List Instances and press Enter . You will receive a list of the instance name, both the LDAP and SSL port numbers, the location of the database, and its status.

How to run GPResult on a remote client with PowerShell

In the past, to run the GPResult command, you would need to either physically visit this client, have the user do it, or use and RDP connection.  In all cases, this will disrupt the user.  First, you need PowerShell remoting enabled on the target machine.  You can do this via Group Policy . Open PowerShell and type this command. Invoke-Command –ScriptBlock {GPResult /r} –ComputerName <ComputerName> Replace <ComputerName> with the name of the target.  Remember, the target needs to be online and accessible to you.

Error icon when creating a GPO Preference drive map

You may not have an error at all.  Take a look at the drive mapping below. The red triangle is what threw us off.  It is not an error.  It is simply a color representation of the Replace option of the Action field in the properties of the drive mappings. Create action This give you a green triangle. The Create action creates a new mapped drive for users. Replace Action The Replace action gives you a red triangle.  This action will delete and recreate mapped drives for users. The net result of the Replace action is to overwrite all existing settings associated with the mapped drive. If the drive mapping does not exist, then the Replace action creates a new drive mapping. Update Action The Update action will have a yellow triangle. Update will modify settings of an existing mapped drive for users. This action differs from Replace in that it only updates settings defined within the preference item. All other settings remain as configured on the mapped drive. If the