VMware Cloud Community
schmitz3michael
Contributor
Contributor
Jump to solution

get portgroup Name from VC:VirtualMachine

Hi,
I'm trying to create a small action to get the name of a distributed Portgroup from a virtual machine.

I have a Input named vRAVirtualMachine (Type: VC:VirtualMachine).

Then I try to get the VC:Network object and the name value from this object:

var myVcNetwork = new VcNetwork();
myVcNetwork = vRAVirtualMachine.network;
var myPortgroupName = myVcNetwork.name;
System.log(myPortgroupName);

 

The System.log output is still "undefined", but I can't see what's wrong.

Does anyone here see the mistake I made, or is there perhaps a better solution to get the name of the port group from a VM?

Reply
0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert
Jump to solution

The network attribute is an array, so you need to index it:

var myPortgroupName = vRAVirtualMachine.network[0].name
System.log(myPortgroupName);

View solution in original post

Reply
0 Kudos
2 Replies
xian_
Expert
Expert
Jump to solution

The network attribute is an array, so you need to index it:

var myPortgroupName = vRAVirtualMachine.network[0].name
System.log(myPortgroupName);
Reply
0 Kudos
schmitz3michael
Contributor
Contributor
Jump to solution

Oh, shame on me! Thank you, I didn't see that...

Reply
0 Kudos