dell/OpenManage-Enterprise

Get-DeviceList.ps1 only returns 100 hosts

jzcmyz opened this issue · 2 comments

When i run get-devicelist.ps1 it creates $DeviceData that only has 100 entries.

I think 100 is the default number of records to return.

We have more the 100 hosts.

image

50 may be the default - sounds like a possible bug in pagination logic - do you have between 100 and 150 devices?

50 is default num in each url api request. So I modify the get_device_list() function.
I have 230 devices, it works.

def __get_device_list(self):
    base_link_url = self.__base_uri + '/api/DeviceService/Devices'
    self.json_data = {}

    data = self.__get_device_from_uri(base_link_url)
    total = 0
    if data['@odata.count'] <= 0:
        print("No devices managed by %s" % self.__session_input["ip"])
        return False
    else:
        total = data['@odata.count']
        self.json_data['value'] = data['value']
    for n in range(1,int(math.ceil(total / 50.0))):
        next_link_url = base_link_url + "?$skip=" + str(n*50) + "&$top=50"
        data = self.__get_device_from_uri(next_link_url)
        self.json_data['value'] += data['value']
    return True