{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1113,"path":"api-reference/server-api-reference/c_StartDiscoveryAPI.md","title":"StartDiscovery - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# StartDiscovery- Global\n\nThe StartDiscovery script include provides methods to start discovery jobs.\n\nUse this script include during the discovery scanning phase.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## StartDiscovery - addAdditionalIP\\(String status, String ip, String sensor\\)\n\nAdds an IP \\(or comma-separated list of IPs\\) to an existing discovery \\(used by networks discovery\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|status|String|The discovery status|\n|ip|String|An IP address, or a comma-separated list of IP addresses.|\n|sensor|String|The discovery sensor|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## StartDiscovery - discoverFromSchedule\\(String ip, Boolean samePhase, String sensor\\)\n\nHandles discovery of devices \\(whether basic or advanced\\) from a schedule.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ip|String|An IP address, or a comma-separated list of IP addresses.|\n|samePhase|Boolean| |\n|sensor|String|The discovery sensor|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## StartDiscovery - getCancelScript\\(\\)\n\nReturns the cancel script.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The cancel script|\n\n## StartDiscovery - scheduleCancelJob\\(\\)\n\nIf the schedule specifies a cancel time, if necessary, schedules a job to cancel the discovery.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThe following example shows how to use the scheduleCancelJob\\(\\) method to cancel a current discovery job.\n\n```\nvar discoveryScheduleGR = new GlideRecord('discovery_schedule'); // Create a discovery schedule Gliderecord\ndiscoveryScheduleGR.get('name', 'Disco'); // Put the discovery schedule job name\n\nvar discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); \nvar discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.167.31.231'); // Initiate discovery\ngs.info(discoveryStatusSysId); // Display the sys_id of the discovery status record\n\ndiscoveryStatusSysId.scheduleCancelJob(); // Schedule a cancel job, located in the sys_trigger table\n\n```\n\nOutput:\n\n```\nOperation\tTable\t\tRow Count\ninsert\t\tdiscovery_result\t1\nupdate\t\tdiscovery_status\t1\ninsert\t\tsys_trigger\t     1\ninsert\t\tdiscovery_status\t1\n*** Script: Fired started event for: undefined Disco\n*** Script: Scheduling Discovery DIS0010023 for cancellation at 2022-02-13 16:42:44\n*** Script: 1828b05f1b6d811070cb96c6b04bcb53\n```\n\n## StartDiscovery - startFromIP\\(DiscoverySchedule schedule, String ip\\)\n\nStarts a discovery for a single IP using the specified schedule to get information such as MID servers and behaviors.\n\n<table id=\"table_elc_1cv_tt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nschedule\n\n</td><td>\n\nDiscoverySchedule\n\n</td><td>\n\nDiscoverySchedule instance for the schedule to use.\n\n</td></tr><tr><td>\n\nip\n\n</td><td>\n\nString\n\n</td><td>\n\nIP address to discover.Format: dot-formatted string\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the status record created.|\n\nThis example uses the startFromIP\\(\\) method to obtain the record that contains the discover information.\n\n```\n// Get a discovery schedule gliderecord\nvar discoveryScheduleGR = new GlideRecord('discovery_schedule'); \ndiscoveryScheduleGR.get('name', 'Discover Management Range 172.x.x.x');\n\n// Create a DiscoverySchedule object to get information such as MID servers and behaviors\nvar discoverySchedule = new DiscoverySchedule(discoveryScheduleGR); \nvar discoveryStatusSysId = new StartDiscovery().startFromIP(discoverySchedule, '172.1.1.10');\n \n// Sys_id of the genterated status record\ngs.info(discoveryStatusSysId);\n```\n\nOutput:\n\n```\n9d3c1197c611228701cd1d94bc32d76d\n```\n\n## StartDiscovery - startFromSchedule\\(GlideRecord schedule, GlideRecord job\\)\n\nInvoked by the discovery script include to kick off a scheduled \\(or discover now\\) discovery.\n\n|Name|Type|Description|\n|----|----|-----------|\n|schedule|GlideRecord|The instance of discovery\\_schedule that this discovery is based on.|\n|job|GlideRecord|The instance of sys\\_trigger that triggered this discovery.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n"}}