Update-GphSchemaCache.ps1

function Update-GphSchemaCache
{
  <#
      .SYNOPSIS
      Updates the AD Schema Cache.
 
      .DESCRIPTION
      This Cmdlet refreshes the Schema Cache. It is a helper-Function for Add-GphGpoDefaultPermissions to
      speed up the Permission Canche for New GPOs.
 
      .EXAMPLE
      Upddate-GphSchemaCache
      Updates the AD Schema Cache
       
      .NOTES
      Author: Holger Voges
      Date: 2018-11-16
      Version: 1.0
  #>

  [CmdletBinding()]
  param()
  
  Try 
  {
    $SchemaMaster = (Get-ADForest).SchemaMaster.Split('.')[0]
    $RootDSE = [ADSI] "LDAP://$SchemaMaster/RootDSE"
    $RootDSE.put("SchemaUpdateNOW",1)
    $RootDSE.SetInfo()
    Write-Information -MessageData 'Update successfull'
  }
  Catch
  {
    $_.Exception.Message
  }
}