A Post-Clone script to Deactivate and Cancel Discovery Schedules


Discovery Schedules will be copied as part of a clone. They will then run on the same schedule on the clone target instance, and may cause performance problems for the instance, MID Servers of the target instance, or the devices and servers that are being Discovered due to the unwanted additional probes running against those IPs. Customers generally don't need or want the CMDB updated so regularly or at all on sub-production instances.

This KB provides a way of automatically turning off Discovery jobs on any sub-prod instances immediately after a clone.

Release or Environment



This solution leverages the Post-Clone Cleanup Script platform feature. More details of what that is are in the docs.

  1. Navigate to: System Clone -> Clone Definition -> Cleanup Scripts
  2. Click New
  3. Name: De-activate And Stop Discovery Schedules
    Script: (see below)
  4. Submit
Custom post-clone cleanup script based on Service-Now KB0789119
David Piper, 12/12/2019

This will deactivate any scheduled discoveries on the clone target after the clone, and stop any that are already started.

function deactivateAndStopDiscoverySchedules() {
	// De-activate Discovery Schedules
	var schedules = new GlideRecord('discovery_schedule');
	while (schedules.next()) {
		schedules.active = false;
	// Stop any running schedules
	var statuses = new GlideRecord('discovery_status');
	while (statuses.next()) {
		var dac =  new SncDiscoveryCancel();

Alternatively, an update set is attached containing this script.