Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Mark Roethof
Tera Patron
Tera Patron

Hi there,

When creating new Instance Scan Scan Checks, you will face Scan Checks which you might only want to run if a certain Plugin has been activated. Especially when you are working for several customers and wanting to distribute Scan Checks on several different customer instances. Out-of-the-box, Instance Scan does not come with an option, a configurable field for example, which you can tick to select the plugin which should be active in order to run a Scan Check. So is there something we can do about this?


Options

Several options could be thought of, one could be deactivating Scan Checks manually. Another option might be to use the Script field on Scan Checks, this can be seen in some out-of-the-box Scan Checks and Instance Troubleshooter Scan Checks where scripted Plugins are checked. In my opinion, this is not the correct way to go and a poor design by ServiceNow. Why? The Run Condition field!


Run Condition

Before Scan Checks are executed, the Run Condition field is evaluated. If it is true (or blanc), then the Scan Check will be executed. When having the actual condition within the Script field of a Scan Check, the Scan Check always runs. It's the same behavior as for example the Condition field on Business Rules.

Additionally on the overhead of always running the Scan Check when using the Script field instead of the Run Condition field, this will make scores collected by Instance Scan incorrect.


GlidePluginManager.isActive

So we should use the Run Condition field, though what to add? A common method is the "GlidePluginManager" API. The GlidePluginManager API provides a method for determining if a plugin has been activated.

Knowing this, to query if a specific Plugin is activated, we could come up with:

GlidePluginManager.isActive('plugin_id')

Or, to query if a specific Plugin has not been activated, we could come up with:

!GlidePluginManager.isActive('plugin_id')

 

Result

Just add this small line of code to the Run Condition field of the Scan Checks where you would like to use this. When the Scan Check is triggered, the Run Condition field will first be evaluated and depending on the result the Scan Check will be executed.

find_real_file.png

That's it, not much more to it!

---

And that's it actually. Hope you like it. If any questions or remarks, let me know!

👍
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share projects on Instance Scan I published?
- Instance Scan


Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn

Version history
Last update:
‎06-12-2022 10:29 PM
Updated by: