Enable-GphGlobalStore.ps1

#Requires -RunAsAdministrator
function Enable-GphGlobalStore
{
  <#
      .SYNOPSIS
      Sets the Default Policy Template Store to the Central Policy Store.
 
      .DESCRIPTION
      When the Group Policy Editor is started, it searches for a Central Policy Store by Default, which
      is located on each Domain controller inside the Sysvol-Share. This Cmdlets sets the Central Store
      as default, which might be necessary after switching the default to the Local Store with
      Enable-GphLocalStore.
 
      .EXAMPLE
      Enable-GphGlobalStore
      Sets "\\<your Domain>\Sysvol\<your Domain\Policies\PolicyDefinitions" as the Default Store for Policy Templates.
 
      .NOTES
      Author: Holger Voges
      Date: 2018-11-16
      Version: 1.0
  #>

  [cmdletbinding()]
  param()    
    
    If ( (Get-OsVersion).Versionnumber -lt 6.3)
    {
      Throw 'Switchting between Localstore and Globalstore needs at Least Windows 8.1'
    }
    
    $LocalStoreKey = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Group Policy\'
    Try 
    {
      If (-not ( test-path -Path $LocalStoreKey ))
      {
        $null = New-Item -Path $LocalStoreKey
        $Null = New-ItemProperty -Path $LocalStoreKey -Name ENABLELOCALSTOREOVERRIDE -PropertyType DWord -Value 0
      }
      Else
      {
        Set-ItemProperty -Path $LocalStoreKey -Name ENABLELOCALSTOREOVERRIDE -Value 0
      }

      Write-Verbose "$LocalStoreKey set to 0"
    }
    Catch
    {
        Write-Error $_.Exception.Message
    }
}