KSC Open API  13.1
Kaspersky Security Center API description
int HostGroup::FindHosts ( wstring  wstrFilter,
array  vecFieldsToReturn,
array  vecFieldsToOrder,
params  pParams,
int  lMaxLifeTime,
[out] wstring  strAccessor 
)

Finds hosts by using string filtering.

Finds hosts after filtering by the wstrFilter string and creates the server-side collection of the found hosts. Search is performed in the hierarchy of Administration Servers.

Parameters:
wstrFilter(wstring) string for filtering by the host attributes. See Syntax for filtering the search results.
vecFieldsToReturn(array) array of the host attributes names to return. See List of the host attributes for the attribute names.
vecFieldsToOrder(array) array of containers, each of them containing two attributes:
pParams(params) extra options. The possible attributes are listed below:
  • KLGRP_FIND_FROM_CUR_VS_ONLY

For more information, see Extra search attributes for hosts and administration groups.

Parameters:
lMaxLifeTime(int) maximum lifetime of the result set, in seconds. Contains no more than 7200 seconds.
[out]strAccessor(wstring) result set ID. Identifier of the server-side ordered collection of found hosts. The result set is destroyed and associated memory is freed in the following cases:
Returns:
(int) number of found hosts.
Note:
This method cannot find the hosts in the Administration Servers hierarchy. Use the HostGroup.FindHostsAsync method instead.
See also:

See also how to use the KlAkOAPI Python package:

            def FindHostsByQueryString(server, strQueryString):
                print("Query string: " + strQueryString)
                strAccessor = KlAkOAPI.HostGroup.KlAkHostGroup(server).FindHosts(strQueryString, ["KLHST_WKS_HOSTNAME", "KLHST_WKS_DN"], [], {'KLGRP_FIND_FROM_CUR_VS_ONLY': True}, lMaxLifeTime = 60 * 60).OutPar('strAccessor')
                nStart = 0
                nStep = 100
                oChunkAccessor = KlAkOAPI.ChunkAccessor.KlAkChunkAccessor (server)    
                nCount = oChunkAccessor.GetItemsCount(strAccessor).RetVal()
                print("Found hosts for query string:", nCount)
                oResult = KlAkOAPI.Params.KlAkArray([])
                while nStart < nCount:
                    oChunk = oChunkAccessor.GetItemsChunk(strAccessor, nStart, nStep)
                    oHosts = oChunk.OutPar('pChunk')['KLCSP_ITERATOR_ARRAY']
                    for oObj in oHosts:
                        print("Found host: " + oObj["KLHST_WKS_DN"]);
                        oResult.Add(oObj.GetValue("KLHST_WKS_HOSTNAME"))
                    nStart += nStep
                return oResult
            def main():
                server = KlAkOAPI.AdmServer.KlAkAdmServer.Create("https://ksc.example.com:13299", "username", "password", verify = False)
                oHosts = FindHostsByQueryString(server, "(KLHST_WKS_FQDN=\"" + socket.getfqdn() + "")")
            
See also:
Sample. Registering update agents for hosts in group.