Discovery Patterns - Add extension section in Patterns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2025 10:41 PM
In this guide, we'll learn how to customize Discovery Patterns in ServiceNow.
Discovery Patterns: Discovery patterns are predefined or customized sets of instructions used to automatically identify, classify, and gather information about assets and configuration items within an IT environment.
For this following requirement we will two discovery operations:
- Parse Command Output: Parse Command Output is used to extract specific data from the output of a command run on a target device during discovery. Define parsing determines the strategy used to extract information such as Delimited text, RegEx etc..; Delimiters and Positions are used to determine what specific information will be captured from the Output.
- Set Parameter Value: Set Parameter Value is one of the simplest operations to use. It allows the pattern to always populate a variable with a constant value, which can be a string or a different variable. It is an easy way to populate a variable and can be used multiple times throughout a pattern to gather information in temporary variables.
Use case: ServiceNow retrieves the baseboard serial number by default as part of the out-of-the-box (OOB) pattern functionality. However, we need to retrieve the system serial number for Windows servers instead
As shown in the below screenshot windows server consists of multiple serial numbers (system, baseboard, chassis, bios, uuid).
As per ServiceNow OOO configurations it discovered baseboard serial number in the Windows Server table
We will customize the patterns to discover the System Serial Number and populate in the CMDB accordingly.
Steps to be followed:
Step1: As part of this requirement, we will create a custom field on the Windows Server table called "System Serial Number.
Step 2: Add an Extension step in the discovery pattern to retrieve the System Serial Number.
Step 3: Navigate to Discovery Patterns in the Application Navigator, and search for the Windows Server patterns.
Step 4: Under the Extension section, click New, then provide a Name and set the Order.
Step 5: Open the newly created Extension section.
a. Provide a Name for the step and select the Operation as Parse Command Output
b. In the Set Command Details field, enter the following command:
wmic bios get serialnumber
c. To view the command execution results, enable Debug Mode and click on Run Command, as shown in the screenshot below:
d. The output contains two lines. To exclude the header text (SerialNumber), add "SerialNumber" to the Exclude Lines field. This ensures that only the actual serial number value is captured
e. Create a temporary variable to store the output. Click on Add Variable and set the position to 1.
f. Click on New Step from the left navigator under Steps
g. Select Operation as Set Parameter Value, and in the Value field, provide: EVAL(javascript: req = ${temp};
h. In the Name field, select the System Serial Number custom field that we created in Step 1.
i. Click Save and Publish the extension section.
j. Navigate to MID Servers and click Pattern Sync to MID to sync the custom-developed discovery steps.
Step6: Run the discovery on any Windows Server to populate the System Serial Number into the custom-created field.
Now, both the Baseboard Serial Number and System Serial Number are successfully populated in their respective fields.
- The Baseboard Serial Number is populated automatically through the out-of-the-box (OOB) discovery functionality, which uses default ServiceNow patterns to retrieve and store this data.
- The System Serial Number, on the other hand, is populated via a custom-developed discovery pattern, tailored specifically to retrieve this data from Windows servers by querying the appropriate system information.
This approach ensures that all hardware identification data is captured accurately and consistently, with the baseboard serial number provided through OOB functionality and the system serial number retrieved via custom logic for Windows servers. This also improves asset tracking and enhances data accuracy in the CMDB, helping IT teams better manage their infrastructure
@Servicenow #itom #cmdb #patterns
Please mark solution as helpful if you founds as useful.
Thanks,
Vijay. Y