Add Binary Value to Reg key With Set-Item

This topic contains 6 replies, has 4 voices, and was last updated by Profile photo of Corey Thomas Corey Thomas 1 year, 8 months ago.

  • Author
    Posts
  • #22988
    Profile photo of H Man
    H Man
    Participant

    Hello I am trying to add website to iE10 Compatibility view

    here is what i have so far

    $key  = "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft"
    
    if(-Not (Test-Path "$key\Internet Explorer")) {
        New-Item -Path $key -Name "Internet Explorer" | Out-Null
    }
    
    if(-Not (Test-Path "$key\Internet Explorer\BrowserEmulation")) {
        New-Item -Path "$key\Internet Explorer" -Name "BrowserEmulation" | Out-Null
    }
    
    if(-Not (Test-Path "$key\Internet Explorer\BrowserEmulation\PolicyList")) {
        New-Item -Path "$key\Internet Explorer\BrowserEmulation" -Name "PolicyList" | Out-Null
    }
    
    
    
    
    $domains = @("google.com","192.168.1.0/24")
    
    $regkey = "$key\Internet Explorer\BrowserEmulation\PolicyList"
    
    foreach($domain in $domains) {
     
            New-ItemProperty -Path $regkey -Name $domain -Value $domain -PropertyType String | Out-Null
     
    }
    
    
    

    any help would be greatly appreciated

  • #22994
    Profile photo of Don Jones
    Don Jones
    Keymaster

    It would be useful to know what you need help with, more specifically. It's a little difficult to kinda stare at your existing code and understand what you are having problems with.

  • #23009
    Profile photo of H Man
    H Man
    Participant

    I am trying to add Google to the compatibility view in ie10 thru the registry using powershell Any suggestions?

  • #23010
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Well, without knowing what is, or is not, working, I don't have any suggestions, no. You appear to be using the correct syntax to modify the registry, but you didn't mention if you're getting any errors or if the code simply isn't doing what you want.

  • #23084
    Profile photo of Corey Thomas
    Corey Thomas
    Participant

    Does the script work? Meaning, does it successfully add the keys you are looking to add?

  • #23125
    Profile photo of H Man
    H Man
    Participant

    It creates the Key but adding the Binary value of the key is the issue. When i export the key i get this

    [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData]
    "UserFilter"=hex:41,1f,00,00,53,08,ad,ba,02,00,00,00,62,00,00,00,01,00,00,00,\
      02,00,00,00,0c,00,00,00,31,9a,b4,93,b1,59,d0,01,01,00,00,00,0e,00,70,00,6f,\
      00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,6f,00,72,00,67,00,\
      0c,00,00,00,1b,9d,3d,a0,b1,59,d0,01,01,00,00,00,0b,00,66,00,6f,00,78,00,6e,\
      00,65,00,77,00,73,00,2e,00,63,00,6f,00,6d,00
    

    I need to be able to convert the hex to binary in order to use the Set-Item cmdlet, like this

    Set-ItemProperty -Path . -Name Test -Value ([byte[]](0x33,0x32,0xFF))
    

    not quite sure how to do that part yet

  • #23144
    Profile photo of Corey Thomas
    Corey Thomas
    Participant

    Did some digging around, could you use this key instead? It uses group policy instead so it's easier to manage.

    HKCU\Software\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList

    Add a new string value for a website with the same data and it will make that site run in compatibility mode.

    Example:

    *.google.com

    This policy setting allows you to add specific sites that must be viewed in Internet Explorer 7 Compatibility View.

    If you enable this policy setting, the user can add and remove sites from the list, but the user cannot remove the entries that you specify.

    If you disable or do not configure this policy setting, the user can add and remove sites from the list.

You must be logged in to reply to this topic.