Before we had the VCSA (Vcenter Server Appliance) we had a Windows Vcenter Server.
We had the PowerCLI installed locally.
There, we could say
Get-VM -Name * | Sort-Object | %{
....
to get a list of all VMs registered in Vcenter.
Now we have the Appliance.
I installed the vMA (management assistant) too.
I registered the vcenter appliance, I am successfully connected to it, but I am unable to simply retrieve a list of VMs like above.
It always wants me to connect to a single ESXi host to perform a listing.
Now to me that seems like a step backward.
How would you do this?
Would you use vMA at all? Maybe use vCLI? Or stick with PowerCLI, but then I would need again to install a Windows machine just to run my scripts…..
Best Answer
I have no experience with the vma, but I suppose it has the vmware Perl SDK installed for you (according to this post virtually ghetto it should). In it you have lots of utils and I think this one is the one you are looking for:
vidiscovery.pl
If you do not wish to enter the credentials every time, then you need to setup the credendial store first.
[edit] Actually, I just tried it and while it kind of works, it is very slow because it gets all the info about every entity. Not very efficient. So I just wrote a very small script and this is all it takes:
This presupposes that you have a $HOME/.visdkrc file in place with the correct info:
And as you said you have the vma, all the libraries should already be there for you. This script gets me all the vm's (just their names in under 1 second). If you do not have a CA in place and your virtual center has a self signed certificate you should set this envvar first or the Perl lwp library will bomb out when running the script: