How do BULK retire or delete asset records without deleting or retiring corresponding CI record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 03:00 PM
We have an ask to delete or retire asset records for virtual machines that have been accidentally created over some time. We need to delete or retire over 4000 records without affecting the corresponding virtual server CI. I know you can "delete asset only" from list view, but this is impractical for this many assets. So my question - Is there a way to bulk delete or retire assets without affecting the CI (leaving the CI intact)?
- Labels:
-
Enterprise Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 05:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 04:50 AM
There should be an On Before business rule [Prevent deleting of non-terminated VM] for the VMWare CIs that prevents their deletion unless the state = ‘terminated’ and correlation_id is empty. It should be safe to delete the assets manually by an admin, and you'll get an error/info message telling you want what done with the CI (deleted or kept).
For a large amount of VMWare instances you can use this script:
var gr =new GlideRecord('alm_hardware');
gr.addEncodedQuery(‘model_category=38c9ada747613000880d1386ffde2707’);
gr.query();
gr.deleteMultiple();
I'd export the VMWare Instance Assets and CIs so you have an off-line record, just in case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 08:05 AM
Theroz: You should be able to use the same script include and function in a fix script to delete the asset only that the UI Action uses.
The UI Action script is:
var a = new AssetandCI();
a.deleteAssetOnly(current);
Your fix script could be something like this:
var aRec = new GlideRecord('alm_hardware');
aRec.addQuery('model','925c8736dbeb00100606e119139619fe');
aRec.query();
while(aRec.next()){
var aDelete = new AssetandCI();
aDelete.deleteAssetOnly(aRec);
}
Let me know if that works. Please test in a development environment.
-Akash