{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1063,"path":"api-reference/server-api-reference/c_MIDServerFinderAPI.md","title":"MIDServerFinder - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# MIDServerFinder- Global\n\nThe MIDServerFinder script include provides methods to find a list of MID Servers for specified IP addresses.\n\nUse in server scripts to get the MID Server list.\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## MIDServerFinder - MIDServerFinder\\(\\)\n\nCreates an instance of MIDServerFinder.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## MIDServerFinder - getMIDServers\\(\\)\n\nGets the names of MID servers available for a given range and capability.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array|An array of MID server names. If no MID servers are available, returns an empty array.|\n\n```\nvar msf = new MIDServerFinder();\nmsf.setRanges('10.10.10.1-10.10.11.254');\nvar msnames = msf.getMIDServers();\n \nfor(var i=0; i<msnames.length; i++) {\n  gs.print(msnames[i]);\n};\n```\n\n## MIDServerFinder - getMIDServersBySysId\\(\\)\n\nGets the sys\\_ids of MID servers available for a given range and capability.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Array|An array of MID server sys\\_ids. If no MID servers are available, returns an empty array.|\n\n```\nvar msf = new MIDServerFinder();\nmsf.setRanges('10.10.10.1-10.10.11.254');\nvar msids = msf.getMIDServersBySysId();\n \nfor(var i=0; i<msids.length; i++) {\n  gs.print(msids[i]);\n};\n```\n\n## MIDServerFinder - getStatusMessage\\(\\)\n\nGets the state of the finder operation.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The status message|\n\n```\nvar msf = new MIDServerFinder();\ngs.print(msf.getStatusMessage());\n```\n\n## MIDServerFinder - setActive\\(Boolean flag\\)\n\nSets whether to look for active or inactive MID servers. By default, searches are for active MID servers unless inactive is specified by this method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|flag|Boolean|If true, look for inactive MID servers. If false, do not look for inactive MID servers.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar msf = new MIDServerFinder();\nmsf.setActive('true');\n```\n\n## MIDServerFinder - setCapabilities\\(Array capabilities\\)\n\nSets the technologies for which to look.\n\n|Name|Type|Description|\n|----|----|-----------|\n|capabilities|Array|Contains a list of capabilities, for example - `capabilities = [\"ssh\",\"wmi\",\"snmp\",{\"os_domain\":\"disco\"},{\"phase\":1}];`|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar msf = new MIDServerFinder();\nmsf.setRanges('10.10.10.1-10.10.11.254');\nvar capab = [\"ssh\",\"wmi\",\"snmp\"];\nmsf.setCapabilities(capab);\n```\n\n## MIDServerFinder - setDebug\\(Boolean onOrOff\\)\n\nTurns debugging on or off.\n\n|Name|Type|Description|\n|----|----|-----------|\n|onOrOff|Boolean|True to turn on debugging; false to turn debugging off.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar msf = new MIDServerFinder();\nmsf.setDebug('true');\n```\n\n## MIDServerFinder - setRanges\\(String ranges\\)\n\nSets the range of IP addresses for which to look.\n\n<table id=\"table_uvk_jfl_zt\" 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\nranges\n\n</td><td>\n\nString\n\n</td><td>\n\nA comma-separated list in one of these formats. -   IP addresses \\(10.10.10.1, 10.10.10.2\\)\n-   IP networks \\(10.10.10.0/23\\)\n-   IP ranges \\(10.10.10.1-10.10.11.254\\)\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar msf = new MIDServerFinder();\nmsf.setRanges('10.10.10.1-10.10.11.254');\n```\n\n## MIDServerFinder - setRangesByIPOrHostname\\(String ipOrHostname\\)\n\nDetermines if the input is a single IP or a hostname, and passes the IP or multiple IPs to the setRanges\\(\\) method.\n\nIf the value of ipOrHostname is an IP address, it is passed into the setRanges\\(\\) method. It the value is a hostname, we look up the DNS table \\(cmdb\\_ip\\_address\\_dns\\_name\\) to try resolving the hostname. The result, either an IP or multiple IPs, is then passes into the setRanges\\(\\) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|ipOrHostname|String|The IP address, IP range, or host name.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar msf = new MIDServerFinder();\nmsf.setRangesByIPOrHostname('10.10.10.1-10.10.11.254');\n```\n\n"}}