- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 03:45 AM
Hi, for a certain class of devices in our Org the data has been updated manually such that the Name field contains MAC address for the device. A sample name value is abc000832c61d1c.domain.net where the 12 digit MAC address is between abc and .domain.net. I need help with a fix script to get the MAC address field populated from this value in the required format like 00:08:32:c6:1d:1c.
Please suggest if you have come across this scenario. Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 08:34 AM
Hi Brahmjeet,
So I figured out the mistake, had to make use of slice:
var extractedString = inputString.slice(3).replace('.domain.net', '');
and then added the usuals
var newMac = extractedString.replace(/(.{2})/g,"$1:").slice(0,-1);
//gs.print(newMac);
}
macad.mac_address = newMac;
gs.info(newMac);
macad.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 08:34 AM
Hi Brahmjeet,
So I figured out the mistake, had to make use of slice:
var extractedString = inputString.slice(3).replace('.domain.net', '');
and then added the usuals
var newMac = extractedString.replace(/(.{2})/g,"$1:").slice(0,-1);
//gs.print(newMac);
}
macad.mac_address = newMac;
gs.info(newMac);
macad.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 11:55 AM
Hey Prashanth,
great! I hope it's resolved now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 05:49 AM
Hi Brahmjeet, yup it is resolved now. Thanks.