VMware Cloud Community
QuincySanders
Contributor
Contributor

Command for listing all vm's within a vApp ?

This is seemingly simple, however I have yet to find success with this. How do I list all of the vm's in within a vApp along with all of the information about these vm's, namely thier IP, Ram, Compute, etc

Reply
0 Kudos
9 Replies
CSIEnvironments
Enthusiast
Enthusiast

CIvms inside a CIvApp in terms of vCloud Director or do you mean regular vApps? If the former you can do this:

get-civapp "CIvAppNAME" | get-civm | select Name, MemoryMB, CpuCount, Status | ft -AutoSize

Depending on what networking the VM is connected to, will determine what you use to get the IP address. You can find it in the ExtensionData property. Probably $CIvm.ExtensionData.GetNetworkConnectionSection().NetworkConnection[0] if there is only one nic.

Reply
0 Kudos
QuincySanders
Contributor
Contributor

Thanks for your reply. Is this something I need to run from powershell with the vCloud snapin? If so, how do I load the vCloud snap-in into powershell ? This is my presumption because when running this command from PowerCLI I get an error.

Reply
0 Kudos
CSIEnvironments
Enthusiast
Enthusiast

Is this for vCloud Director?

If so then when you installed PowerCLI did you tick the box to install PowerCLI for vCloud Director? If not you will need to run the PowerCLI installer again and make sure you check the box that says "PowerCLI for vCloud Director"

Second the first command errored because you did not have a space between ft and -autosize

Third does get-civapp return anything?

If not try this:

Add-PsSnapin VMware.VimAutomation.Core

Add-PsSnapin VMware.VimAutomation.Cloud

Then try get-civapp.

Reply
0 Kudos
QuincySanders
Contributor
Contributor

Thanks for your reply. Yes, this is for vCD. Yes, I had the vCloud installed from when I installed PowerCLI, however I added the snapin to powershell and I am getting better results. When I de 'Get-CIVapp' it returns my list of vApp's, including the vApp in question. However, when I insert that name into your previous command, the return is blank.

Reply
0 Kudos
CSIEnvironments
Enthusiast
Enthusiast

Please run the following and paste the results:

get-civapp "TLPro*" | select -ExpandProperty Name

Reply
0 Kudos
QuincySanders
Contributor
Contributor

Thanks for the response. I get the same thing, I've pasted the output.

Reply
0 Kudos
CSIEnvironments
Enthusiast
Enthusiast

The reason is because of the square brackets in your naming convention. vCloud/PowerCLI does not like them. I would remove them from your naming standard. I have escaped them with a backtick. Run the below, it should work:

get-civapp 'TLPro | EALPro `[copy`]' | get-civm | select Name, MemoryMB, CpuCount, Status | ft -AutoSize

Reply
0 Kudos
QuincySanders
Contributor
Contributor

Thanks for the response. That was it! Command works now however, it doesn't display the internal or external ip. Is this possible ?

Reply
0 Kudos
CSIEnvironments
Enthusiast
Enthusiast

It depends how is your networking on the vApp setup...If you are natting, using directly org networks etc...Please post a screenshot or you networking of the vapp and the networking of a vm:

Also please run the following and post the results:

$civapp = get-civapp 'TLPro | EALPro `[copy`]'

$civapp.ExtensionData.GetNetworkConfigSection()

$civapp.ExtensionData.GetNetworkConnectionSection()

You could try the following but it will only work if you using NatRouted networks;

$vm = get-civapp $civapp | get-civm | select -First 1

$vm.ExtensionData.GetNetworkConnectionSection().NetworkConnection[0].ExternalIpAddress

Reply
0 Kudos