0

I try to set local group policy using PowerShell. My goal is to enable

Disable changing home page settings

Below is the PowerShell script:

# Set the values as needed
$dchps_control_panel = "HKCU:\Software\Policies\Microsoft\Internet Explorer\Control Panel"
$dchps_main = "HKCU:\Software\Policies\Microsoft\Internet Explorer\Main"
$homepage = "HomePage"
$enabled = 1
$startpage = "Start Page"
$startpage_value = "www.google.com"

# Test if the Registry Key exists already
if(-not (Test-Path $dchps_control_panel) -or -not (Test-Path $dchps_main) )
{
    # Create Control Panel Key to enable and Main Key
    New-Item -Path $dchps_control_panel -Force
    New-Item -Path $dchps_main -Force
}

# Enable Disable changing home page settings
Set-ItemProperty -Path $dchps_control_panel -Name $homepage -Value $enabled -Type DWord
#
# Set Start Page
Set-ItemProperty -Path $dchps_main -Name $startpage  -Value $startpage_value -Type String

The registry keys both get created. However, when I check the "gpedit.msc" the setting still remains to disable and nothing was configured.

Thanks

Jervis Lin
  • 1
  • 1
  • 1
  • 1
    [How to manage Local Group Policy with Powershell](http://brandonpadgett.com/powershell/Local-gpo-powershell/) – JosefZ Oct 26 '17 at 17:39
  • @JosefZ are there anyways without importing other modules? – Jervis Lin Oct 26 '17 at 18:01
  • 1
    You said that GPedit.msc doesn't reflect the change, but did you check to see if it funtions? I ran the above to import the reg key, and it blocked me from changing the home page in IE. – Cory Knutson Oct 27 '17 at 17:53
  • Here is similar topic, it can help. https://serverfault.com/questions/848388/how-to-edit-local-group-policy-with-script – moni9 Oct 30 '17 at 17:55
  • @CoryKnutson that's exactly like the way you said. It actually solved my problems. – Jervis Lin Oct 31 '17 at 13:43
  • Assuming you are referring to the link that @moni9 posted. If so, one of you should post an answer so that it can be marked as the answer. Thanks! – Cory Knutson Oct 31 '17 at 16:07

1 Answers1

0

As expected, you need additional tools. If you run procmon during the change it'll show you the actual registry key which is under a GUID that I haven't found a way to resolve programmatically.

HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{<GUID>}User\Software\Policies\Microsoft\Internet Explorer\Main\Start Page

Also, if you check the registry.pol you'll see the entry, but you won't be able to edit it directly.

gc C:\Windows\System32\GroupPolicy\User\Registry.pol -Encoding Unicode
spacenomyous
  • 1,319
  • 7
  • 15