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]

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.