Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: FSMO Roles

Posted by on Saturday, March 20, 2004 (PST)

Script: Prints out the owners of the 5 FSMO Roles. Schema Master, Domain Naming Master, PDC Emulator, RID Master, and Infrastructure Master.

 

/**
 *    Script:   FSMORoles.js
 *    Purpose:  Lists owners of the 5 FSMO Roles.
 *    Author:   Daren Thiel
 *    Date:     20 Mar 2004
 *    Web:     
http://www.winscripter.com
 *    Note:     Must be ran in AD environment with sufficient
 *              permission to query LDAP
 **/

GetFSMORoles();
function GetFSMORoles()
{
 try
 {
  print( "FSMO Roles" );
  print( "=====================================" );
  
  //////////////////////////////////////////
  // Find the correct context for this env
  //////////////////////////////////////////

  var rootdse = GetObject( "LDAP://rootDSE" );
  var DNC = rootdse.Get( "defaultNamingContext" );
  var SNC = rootdse.Get( "schemaNamingContext" );
  var CNC = rootdse.Get( "configurationNamingContext" );
  //////////////////////////////////////////
  // schema master
  //////////////////////////////////////////

  var oschema = GetObject( "LDAP://" + SNC );
  var sSchemaMaster = oschema.Get( "fSMORoleOwner" );
  var oNTDS = GetObject( "LDAP://" + sSchemaMaster );
  var oComp = GetObject( oNTDS.Parent );
  print( "Schema Master         : " + oComp.Name );
  
  //////////////////////////////////////////
  // Domain Naming Master
  //////////////////////////////////////////

  var oPart = GetObject( "LDAP://CN=Partitions," + CNC );
  var sDomainNamingMaster = oPart.Get( "fSMORoleOwner" );
  oNTDS = GetObject( "LDAP://" + sDomainNamingMaster );
  oComp = GetObject( oNTDS.Parent );
  print( "Domain Naming Master  : " + oComp.Name );
  
  //////////////////////////////////////////
  // PDC Emulator
  //////////////////////////////////////////

  var oDomain = GetObject( "LDAP://" + DNC );
  var sPDCEm  = oDomain.Get( "fSMORoleOwner" );
  oNTDS = GetObject( "LDAP://" + sPDCEm );
  oComp = GetObject( oNTDS.Parent );
  print( "PDC Emulator          : " + oComp.Name );
  
  //////////////////////////////////////////
  // RID
  //////////////////////////////////////////

  var oRID = GetObject( "LDAP://CN=RID Manager$,CN=System," + DNC  );
  var oRIDMaster  = oRID.Get( "fSMORoleOwner" );
  oNTDS = GetObject( "LDAP://" + oRIDMaster );
  oComp = GetObject( oNTDS.Parent );
  print( "RID Master            : " + oComp.Name );
  //////////////////////////////////////////
  // Infrastructure
  //////////////////////////////////////////

  var oInfra = GetObject( "LDAP://CN=Infrastructure," + DNC );
  var oInfraMaster = oInfra.Get( "fSMORoleOwner" );
  oNTDS = GetObject( "LDAP://" + oInfraMaster );
  oComp = GetObject( oNTDS.Parent );
  print( "Infrastructure Master : " + oComp.Name );
 }
 catch( e )
 {
  print( "Error: " + e.description );  
 }
}
function print( msg )
{
 WScript.Echo( msg );
}

Add Your Comment



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon