- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2020 11:58 PM
Hello,
Does SCCM Integration populate the IP Address field on a Computer record? If yes, please point me to the script/ transform map that does so.
My instance is on the NewYork version and we are using the OOB SCCM 2012 v2 Integration. No modifications have been made to the SQL queries.
I am aware that the IP Address is being pulled in through the data source for Network Adapters but I would like to know if and how this value flows to the Computer record associated with the Network Adapter. Currently, to achieve this requirement I have written a script on the Transform Map for Network Adapters, to populate the IP Address into the corresponding CI.
Please help me with any relevant information.
Thank You,
Nikita
Solved! Go to Solution.
- Labels:
-
Discovery
- 3,228 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 05:52 AM
No, the SCCM integrations (up to and including 2016) do not synchronize the IP address from the SCCM Network import. I have also created an onComplete transform script to do the same thing to accomplish this.
var impSet = new GlideAggregate(import_set.table_name);
impSet.addQuery('sys_import_set', import_set.sys_id);
impSet.addQuery('sys_target_sys_id', '!=', 'NULL');
impSet.groupBy('sys_target_sys_id');
impSet.query();
while (impSet.next()) {
var nic = new GlideRecord('cmdb_ci_network_adapter');
if (nic.get(impSet.sys_target_sys_id)) {
syncIP(nic);
}
}
// Ensure that ip_address field on the base CI is set to one the IP addresses (from cmdb_ci_ip_address) on the NICs, or leave it alone if there were no IPs...
function syncIP(nic) {
//If the ip is already in one of the IPs, then don't go through the IP fix-up...
var IPs = [];
var parentIP = getParentIP(nic.cmdb_ci);
var gr = new GlideRecord('cmdb_ci_network_adapter');
gr.addQuery('cmdb_ci', nic.cmdb_ci);
gr.addQuery('install_status', '!=', 100);
gr.addQuery('ip_address' ,'!=', 'NULL');
gr.orderByDesc('last_discovered');
gr.orderBy('ip_address');
gr.query();
while (gr.next()) {
var ip = gr.ip_address + '';
if (ip == parentIP)
return;
IPs.push(ip);
}
// If there's no IPs, then nuthin' to do...
if (IPs.length == 0)
return;
// If we found a non-localhost IP, then we're done
for (var i = 0; i < IPs.length; i++) {
var nicIP;
try {
nicIP = new SNC.IPAddressV4(IPs[i]);
} catch (e) {
continue;
}
if (!nicIP.isLocalhost() && !nicIP.isLinkLocalAddress()) {
setParentIP(nic.cmdb_ci, nicIP.toString());
return;
}
}
//If we get here, then no good IP is available... so no need to update
}
function setParentIP(ci, ip) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci)) {
gr.ip_address = ip;
gr.update();
}
}
function getParentIP(ci) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci))
return gr.ip_address + '';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2020 05:52 AM
No, the SCCM integrations (up to and including 2016) do not synchronize the IP address from the SCCM Network import. I have also created an onComplete transform script to do the same thing to accomplish this.
var impSet = new GlideAggregate(import_set.table_name);
impSet.addQuery('sys_import_set', import_set.sys_id);
impSet.addQuery('sys_target_sys_id', '!=', 'NULL');
impSet.groupBy('sys_target_sys_id');
impSet.query();
while (impSet.next()) {
var nic = new GlideRecord('cmdb_ci_network_adapter');
if (nic.get(impSet.sys_target_sys_id)) {
syncIP(nic);
}
}
// Ensure that ip_address field on the base CI is set to one the IP addresses (from cmdb_ci_ip_address) on the NICs, or leave it alone if there were no IPs...
function syncIP(nic) {
//If the ip is already in one of the IPs, then don't go through the IP fix-up...
var IPs = [];
var parentIP = getParentIP(nic.cmdb_ci);
var gr = new GlideRecord('cmdb_ci_network_adapter');
gr.addQuery('cmdb_ci', nic.cmdb_ci);
gr.addQuery('install_status', '!=', 100);
gr.addQuery('ip_address' ,'!=', 'NULL');
gr.orderByDesc('last_discovered');
gr.orderBy('ip_address');
gr.query();
while (gr.next()) {
var ip = gr.ip_address + '';
if (ip == parentIP)
return;
IPs.push(ip);
}
// If there's no IPs, then nuthin' to do...
if (IPs.length == 0)
return;
// If we found a non-localhost IP, then we're done
for (var i = 0; i < IPs.length; i++) {
var nicIP;
try {
nicIP = new SNC.IPAddressV4(IPs[i]);
} catch (e) {
continue;
}
if (!nicIP.isLocalhost() && !nicIP.isLinkLocalAddress()) {
setParentIP(nic.cmdb_ci, nicIP.toString());
return;
}
}
//If we get here, then no good IP is available... so no need to update
}
function setParentIP(ci, ip) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci)) {
gr.ip_address = ip;
gr.update();
}
}
function getParentIP(ci) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci))
return gr.ip_address + '';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2020 08:41 AM
Hello Andrew,
I've got a need to re-use your script. Have a couple of questions:
- is this onComplete script for 'SCCM 2016 Network' transform map?
- first 2 lines of the script: 'import_set.table_name' is clear, will be something like 'imp_sccm2016_network', but how can you define 'import_set.sys_id' as a variable in order to use a scheduled import?
- how can I populate the MAC address of Computer CI?
Seems like I've missed something really straightforward. Many thanks in advance for your help.
Regards,
Pavlo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2021 08:10 AM
did it work for anyone?.
var impSet = new GlideAggregate(import_set.imp_sccm2016_network);
impSet.addQuery('sys_import_set', import_set.sys_id);
impSet.addQuery('sys_target_sys_id', '!=', 'NULL');
impSet.groupBy('sys_target_sys_id');
impSet.query();
while (impSet.next()) {
var nic = new GlideRecord('cmdb_ci_network_adapter');
if (nic.get(impSet.sys_target_sys_id)) {
syncIP(nic);
}
}
// Ensure that ip_address field on the base CI is set to one the IP addresses (from cmdb_ci_ip_address) on the NICs, or leave it alone if there were no IPs...
function syncIP(nic) {
//If the ip is already in one of the IPs, then don't go through the IP fix-up...
var IPs = [];
var parentIP = getParentIP(nic.cmdb_ci);
var gr = new GlideRecord('cmdb_ci_network_adapter');
gr.addQuery('cmdb_ci', nic.cmdb_ci);
gr.addQuery('install_status', '!=', 100);
gr.addQuery('ip_address' ,'!=', 'NULL');
gr.orderByDesc('last_discovered');
gr.orderBy('ip_address');
gr.query();
while (gr.next()) {
var ip = gr.ip_address + '';
if (ip == parentIP)
return;
IPs.push(ip);
}
// If there's no IPs, then nuthin' to do...
if (IPs.length == 0)
return;
// If we found a non-localhost IP, then we're done
for (var i = 0; i < IPs.length; i++) {
var nicIP;
try {
nicIP = new SNC.IPAddressV4(IPs[i]);
} catch (e) {
continue;
}
if (!nicIP.isLocalhost() && !nicIP.isLinkLocalAddress()) {
setParentIP(nic.cmdb_ci, nicIP.toString());
return;
}
}
//If we get here, then no good IP is available... so no need to update
}
function setParentIP(ci, ip) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci)) {
gr.ip_address = ip;
gr.update();
}
}
function getParentIP(ci) {
var gr = new GlideRecord('cmdb_ci_hardware');
if (gr.get(ci))
return gr.ip_address + '';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2022 10:33 AM
Has this script worked for anyone.
I am stuck in similar situation and don't see any wayout with this.
This is bit critical.
Regards,
Hanumant