Pivotal Cloud Foundry Version 1.8.x
When running `cf orgs`, you may find some of the organizations missing and some are duplicates. Whereas Apps Manager GUI or `cf curl /v2/organizations` showing the correct list of organizations.
You will notice this when there are more than 50 orgs, the API results are paginated and while the first page specifies `order-by-name`, the `next_url` for page 2 does not specify this.
So, page 2 is in a different order than page 1 and so the visible result is either missing or duplicated orgs or both.
✗ cf orgs Getting orgs as admin.. name Aorg1 Aorg2 Aorg3 ...... Corg1 Corg2 ...... Porg1 Porg2 Porg3 ....... Rorg1 Sorg1 ..... Sorg1 Porg1 Rorg1
Note that Porg1, Sorg1, Rorg1 are listed twice.
The CLI is behaving correctly. Since `next_url` is incorrect this is a fault of the API.
The issue has been fixed in the versions 1.8.33 and 1.9.11. Either upgrade to versions the issue is addressed or follow the workaround.
Until the issue is addressed, you can use `cf curl /v2/organizations or cf curl '/v2/organizations?order-by=name&results-per-page=100' | jq -r -c '.resources| .entity.name'` to get the accurate list of orgs.
Note- You must install `jq`, which is open source software available from this link.