Setting GC Global Catalog through powershell
Script to set Global Catalog role when not GC's are available
# ---------------------------------------------------------------------------------------------------
function set-GCrole
# ---------------------------------------------------------------------------------------------------
{
Param (
$serverName,
$IsGC = "enable"
)
$dse = [adsi]("LDAP://"+$Servername+"/RootDSE")
$ntds = [adsi]("LDAP://"+$dse.dsServiceName)
# 1 = enable, 0 or nothing = disable
If ($IsGC -eq "disable")
{
$ntds.options = 0
}
else
{
$ntds.options = 1
}
$ntds.SetInfo()
}
# ---------------------------------------------------------------------------------------------------
If ($Args.count -ne 2)
{
write-host "You need to provide the Name of the DC,"
write-host "and the ""enable"" or ""disable"" keyword."
write-host "example: Set-GCrole.ps1 ""server1"" ""enable"""
write-host
exit
}
Set-GCrole $Args[0] $args[1]

Comments