Introduction
This document describes how to filter assets at the time of import to Cisco Energy Management (CEM) with the use of Active Directory Asset Connector.
Prerequisites
Requirements
Cisco recommends that you have knowledge of these topics:
- Basic knowledge of JavaScript
- Basic knowledge of Active Directory
Components Used
The information in this document is based on these software and hardware versions:
- CEM version 5 and later.
- Operational CEM with configured Active Directory Asset Connector.
Note: The script can work with older releases, but it was not tested for this article.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.
Background Information
CEM can import assets from Active Directory. The basic setup of Active Directory Asset Connector allows you to import all the assets from the directory or particular Organisational Units (OU). More advanced filtration can be done with scripts. The script that works on Asset Connector level is executed on every single asset that CEM imports.
Problem
When you import assets from Active Directory, sometimes you need to exclude some particular assets to prevent their import to CEM, because you do not want them to be managed by CEM.
Solution
Use Asset Connector script action that is triggered at the time of asset connector operations.
Step 1. Log in to CEM and navigate to Assets > Import as shown in the image.

Step 2. Edit Active Directory Asset Connector settings as shown in the image.
Step 3. Navigate to Script tab and paste the script to the Custom integration Script window as shown in the image.

var script_name = "AD ASSET CONNECTOR SCRIPT ACTION";
// Get values for current asset
var current_product = dget("product");
var current_hostname = dget('hostname');
// Set variables/arrays of excludeding conditions
var excluded_product_string = "VMware Virtual Platform";
var excluded_hostnames = [
"SUBCA",
"DC1",
"PC3"
];
// Check does the current asset matches exluded product condition
if (current_product == excluded_product_string) {
log(script_name + " Product: " + current_product + " was ignored and will not be imported to CEM.", "INFO");
acignore();
}
// Check does the current asset matches one of the excluded hostnames
for( i = 0; i < excluded_hostnames.length; i++ ) {
if ( excluded_hostnames[i] == current_hostname ) {
log(script_name + " Hostname: " + current_hostname + " was ignored and will not be imported to CEM.", "INFO");
acignore();
}
}
This script verifies Active Directory hostname and product fields and compares them with the excluded assets (excluded_product_string and excluded_hostnames array). If one of them matches, the asset gets ignored and a log entry is created in CEM controller.log.
Note: You can filter assets with the use of different Active Directory fields. Change the filed name to hostname: dget('hostname');
Step 4. Click OK to save the script and then Save changes to Asset Connectors.
Step 5. Execute your Active Directory Asset Connector as shown in the image.
Verify
Verify ignored assets numberas shown in the image.

Related Information