Script to update the operational status field of cmdb_ci_computer table to retired
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2022 04:10 AM
We were trying to run the BG script below to change the operational status of some computers to retired where discovery source is from SCCM and most recent discovery is before Aug 1 2022-
var gr= new GlideRecord("cmdb_ci_computer");
gr.addQuery('discovery_source','SG-SCCM');
gr.addQuery('last_discovered','<','2022-08-01 00:00:00');
gr.addQuery();
while (gr.next()){
gr.setValue("operational_status",5);
gr.update();
}
But this was not working.
Can anyone point out what could be wrong here or anyone who can help with a script to achieve this requirement.
- Labels:
-
Discovery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 02:23 AM
Hi Ankur
Need a favour please.
I have 966 servers in Excel file and need to bulk update Operational Status = Retired.
Appreciate if you can share the script please.
Thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2023 03:48 AM
you should use data load, transform map for this
Please post a new question and add any issues faced there
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2022 04:08 AM
Hi Ankur
Thanks for the reply! It helped.
Can we get to know how does the below script line suggested by you change, if we want to query for not discovered in last 30 days (i.e most recent discovery > 30 days )
gr.addEncodedQuery("last_discovered<javascript:gs.dateGenerate('2022-08-01','00:00:00')");
Thanks & Regards
Arathi Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 11:02 PM
Hi,
Glad to know that my script helped.
Would you mind marking my response as correct and close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 11:07 PM
like this form the filter and copy the query
last_discoveredNOTONLast 30 days@javascript:gs.beginningOfLast30Days()@javascript:gs.endOfLast30Days()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader