Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save realslacker/b4b4b2c8400d16ce58f985cf7f3b1264 to your computer and use it in GitHub Desktop.
Save realslacker/b4b4b2c8400d16ce58f985cf7f3b1264 to your computer and use it in GitHub Desktop.
Pulls the current user's Compatibility Mode settings from the registry and creates a Group Policy Registry Preference XML string for pasting into Group Policy Manager.
<#PSScriptInfo
.VERSION 2018.10.02.1248
.GUID 75bfca34-ff9c-4cac-beab-51a685d42c44
.AUTHOR Shannon Brooks
.COMPANYNAME Brooksworks
.COPYRIGHT Shannon Brooks (c) 2018
.PROJECTURI https://gist.github.com/realslacker/b4b4b2c8400d16ce58f985cf7f3b1264
#>
<#
.DESCRIPTION
Pulls the current user's Compatibility Mode settings from the registry and creates a Group Policy Registry Preference XML string for pasting into Group Policy Manager.
#>
Param()
# Get current CompatibilityMode settings
$UserFilter = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData' -Name 'UserFilter' | Select-Object -ExpandProperty UserFilter
# Convert to HEX string
$UserFilter = ( $UserFilter | ForEach-Object { '{0:x2}' -f $_ } ) -join ''
# Create the XML for pasting into Group Policy Editor
$GroupPolicyXML = @"
<Registry clsid="{9CD4B2F4-923D-47f5-A062-E897DD1DAD50}" name="UserFilter" status="UserFilter" image="17" changed="$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" uid="{9AB3BBC3-6921-4C54-A137-0D10C12D196F}"><Properties action="U" displayDecimal="0" default="0" hive="HKEY_CURRENT_USER" key="Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData" name="UserFilter" type="REG_BINARY" value="$UserFilter"/></Registry>
"@
# Put the XML into the clipboard
$GroupPolicyXML | Set-Clipboard
# Display a message
Write-Information "The current user's Compatibility Mode settings have been converted to an XML string and set in the clipboard for pasting into a Group Policy Registry Preference." -InformationAction Continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment