schmitz3michael
Contributor
Contributor

get portgroup Name from VC:VirtualMachine

Jump to solution

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?

0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert

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

0 Kudos
2 Replies
xian_
Expert
Expert

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

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

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

0 Kudos