How do query in Discover for list hosts if we have fleet agent policy id

I have list of hosts around 1040 i need to query and that list exported to excel.