Add attribute to Global Catalog Replication using PowerShell

Add Attributes to Global Catalog Replication

It is common for IT admins to notice that few AD attributes are not natively in the global catalog replication set. Adding these attributes to the Global Catalog replication set is necessary so that all the DC's in the network carry the updated copies of all the attributes.
 
To add attributes to the Global Catalog Replication set, supply the attribute name as parameter and execute the following PowerShell script. 

Script

<# .SYNOPSIS This script can be used to add Attributes to Global Catalog Replication . .DESCRIPTION This script can be used to add Attributes to Global Catalog Replication . .EXAMPLE C:\PS> C:\Script\Replicate_To_GC.ps1 badPwdCount
To replicate badPwdCount to GlobalCatalogue.
#>

param([String] $attribute )
$strAttrName = $attribute
$boolAddToGC = $true
$root = [ADSI] “LDAP://RootDSE”
$objAttr = [ADSI](“LDAP://cn=” + $strAttrName + “,” + $root.schemaNamingContext)
#You can add to the attributes that are stored in the global catalog by setting the isMemberOfPartialAttributeSet attribute of an attributeSchema object to TRUE.

$objAttr.Put(“isMemberOfPartialAttributeSet”, $boolAddToGC)
$objAttr.setInfo()