VMware Cloud Community
zonghang
Contributor
Contributor

REST API VM list filtre like

Hello,

I want to use VMWare REST API for finding VM. I want to find the VMs with a name 'PW-XXX'. I use /rest/vcenter/vm, but there are too many VM, so I must add a filtre. But I don't have the full name of VM. I want to find all VM with name like 'PW-XXX'. I don't know how can I do. Thanks for your reponse.

0 Kudos
4 Replies
faherne_CTI
Enthusiast
Enthusiast

Hi, you need to specify what programming language you are using and also paste in the code segment you have so far.

 

If you're using PowerShell, all you need to do is run a match on the array of VM names returned.

0 Kudos
zonghang
Contributor
Contributor

Hello, thanks for your reply. 

The problem is I can’t get vm list via rest api. Because in the réponse json, if it have more than 1000 vm, we can’t get all vm by rest api. It must have a filter in url, vm/filter.name=xxx. It must use a full host name. I don’t have the full host name, 

0 Kudos
faherne_CTI
Enthusiast
Enthusiast

Unfortunately this is a known vCenter REST API issue or limitation.

You may need to write your solution with PowerShell/PowerCLI using the SOAP API.

Alternatively, you could log an SR with VMware SDK support, if you have this ability.

0 Kudos
zonghang
Contributor
Contributor

Thanks

0 Kudos