Assuming you’re using CUCM, a BAT export of Directory Numbers is likely your best bet. You can also pull End Users to get Primary extension but that isn’t always reliable since it isn’t cleared when things get disassociated from that user or deleted.