Skip to content

Instantly share code, notes, and snippets.

@Hexalon
Created June 2, 2016 16:26
Show Gist options
  • Save Hexalon/5497a5fd8e8098dff112f240aa35c1ba to your computer and use it in GitHub Desktop.
Save Hexalon/5497a5fd8e8098dff112f240aa35c1ba to your computer and use it in GitHub Desktop.
Disables local GPO store override, creates the key if it does not exist.
#Requires -RunAsAdministrator
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.122
Created on: 6/2/2016 11:24
Created by: Colin Squier <hexalon@gmail.com>
Filename: Disable-LocalStoreOverride.ps1
===========================================================================
.DESCRIPTION
Disables local GPO store override, creates the key if it does not exist.
#>
[CmdletBinding()]
Param ()
if (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Group Policy")
{
Write-Verbose -Message "Registry path exists, checking if the override is enabled."
$GPO = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Group Policy" -Name EnableLocalStoreOverride
If ($GPO.EnableLocalStoreOverride -eq 1)
{
Write-Verbose -Message "Disabling local GPO store override."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Group Policy" -Name EnableLocalStoreOverride -Value 0 | Out-Null
}
}
else
{
Write-Verbose -Message "Creating registry path."
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Group Policy" | Out-Null
Write-Verbose -Message "Creating registry key."
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Group Policy" -Name EnableLocalStoreOverride -Type DWORD -Value 0 | Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment