Delete all vulnerable items and groups

Geeky
Kilo Guru

Hi All,

All the vulnerable items and groups have been imported when I just enabled Knowledge base even before I setup group rules and assignment rules. Now I want to delete them and rerun the import.

Is it fine to do that?

1 ACCEPTED SOLUTION

Dan Daugherty
ServiceNow Employee
ServiceNow Employee

The safest way is to delete your VI's and VG's so that all the business rules run and clean out the related data too.

 OR

You can avoid deleting when testing your group rules by deleting any offending groups and then running this script AS A FIX SCRIPT:

//Create a fix script under the Vulnerability Scope and run this after deleting the Vulnerability Groups you no longer want

var vgr = new sn_vul.VulnerableGroupRule()
var vi = new GlideRecord('sn_vul_vulnerable_item');
//add any queries you may want
vi.setLimit(100); //placed here to prevent a possible massive update that will impact performance. Remove when 100% sure your query is correct and you're prepared to let this run for a while
vi.query();
 while (vi.next()) {
  vgr.groupItemByVulnGroupRule(vi);
}
 
Assignments happen at the group level, so you should get new assignments for the group when the new ones are created.
 
Hope this helps.

View solution in original post

11 REPLIES 11

Dan Daugherty
ServiceNow Employee
ServiceNow Employee

Sorry, it wasn't clear. It was delete everything or don't delete everything and run the script.

 

I've done it both ways successfully.

Hi Dan,

Do you know what else needs to be deleted to rerun the import? I deleted all the VIs and VGs but it's still not reimporting the deleted VIs.

Thanks.

It should re-import the data. Check with SN support. You might not have deleted them completely.

Dan Daugherty
ServiceNow Employee
ServiceNow Employee

Check your thread, Lord Omicron. Andy and I have both responded. Andy's is more thorough than mine but the same answer ultimately.

Slade1
Mega Contributor

Unfortunately I cannot share the steps ... Our integrator provided the scripts to run and I open a ticket for our admin team to execute them.  I know that GlideTableCleaner is used, but it is apparently unsupported (you can read more HERE).  That link also contains information to use Table Cleaner which I believe is supported.