Skip to main content

Validate Primary Domain Controller

Summary

This task validates whether the endpoint is a primary domain controller. It updates the value of the Custom Field - Is Primary Domain Controller custom field, which is then used to create the Machine Group - Infrastructure Master group.

This task should be scheduled to run once per week or month against the Domain Controllers group.

Sample Run

Sample Run 1

Sample Run 2

Dependencies

Implementation

Create the group Machine Group - Domain Controllers.

Create the Custom Field Custom Field - Is Primary Domain Controller.

Create Script

Create a new Script Editor style script in the system to implement this task.

Script Editor

Script Editor 2

Name: Validate Primary Domain Controller

Description: Validate whether the endpoint is an infrastructure master or not and mark the Is Primary Domain Controller custom field.

Category: Custom

Category Image

Script

Start by adding a row. You can do this by clicking the Add Row button at the bottom of the script page.

Add Row Button

Row 1 Function: PowerShell Script

PowerShell Script 1 PowerShell Script 2

Paste in the following PowerShell script and set the expected time of script execution to 300 seconds. This PowerShell function will validate whether the endpoint is an infrastructure master or not.

Import-Module ActiveDirectory
if ((Get-ADDomain -ErrorAction SilentlyContinue).InfrastructureMaster -match $env:COMPUTERNAME) {'Yes'} else {'No'}

PowerShell Script Output

Row 2 Logic: If Then

If Then Logic 1 If Then Logic 2

Row 2a Condition: Output Contains

Enter Yes in the text box.

Output Contains

Row 2b Function: Set Custom Field

Add a new row by clicking on the Add Row button.

Add Row 2

Select Set Custom Field function.

Set Custom Field

When you select Set Custom Field, a new window will open.

Set Custom Field Window

In this window, search for the Is Primary Domain Controller field.

Custom Field: Is Primary Domain Controller

Value: Yes Yes Value

Final Setup

Final Setup 2

Once all items are added, please save the task. The final task should look like the screenshot below.

Final Task Screenshot

Deployment

It is suggested to run the task once per hour against the primary domain controllers or infrastructure masters.

  • Go to Automation > Tasks.
  • Search for Validate Primary Domain Controller Task.
  • Select the concerned task.
  • Click on the Schedule button to schedule the task/script.

Schedule Button

This screen will appear.

Schedule Screen

Click the Does not repeat button.

Does Not Repeat

This pop-up box will appear.

Repeat Options

Select the Week(s) option from the Repeat dropdown and select a day to schedule the task.

Select Week Select Day

Search for Domain Controllers in the Resources* and select the Domain Controllers group.

Domain Controllers

Now click the Run button to initiate the task.

Run Button

The task will start appearing in the Scheduled Tasks.

Scheduled Tasks Scheduled Tasks 2

Output

  • Custom Field Custom Field Output