This solution only gets you the first 100 users. I used advanced_search to get more users, but I believe there is still a maximum. If you reach the maximum you have to use paging.
But how did you figure out what the right search query was?
source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
source_users = source.users.advanced_search(query='!esri_ & !portaladmin', max_users = -1)
for user in source_users.get('results'):
print(user.username)
This is my solution with paging. It works, but I'm not an Python expert, so I'm not sure this is the best method. It searches for 100 users at a time. When there are less than 100 users in the result, it means it has reached the last page.
source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
start = 0
lenght_searchresult = 100
while lenght_searchresult == 100:
source_users = source.users.advanced_search(query='!esri_ & !portaladmin', start = start, max_users = 100)
list_users = source_users.get('results')
lenght_searchresult = len(list_users)
start = start + 100
for user in list_users:
print(user.username)