VMware

This Question is Answered

1 "correct" answer available (10 pts)
2 Replies Last post: Jun 2, 2009 8:40 AM by yboychev  

Identifying networks available to VM's posted: Jun 2, 2009 7:56 AM

Click to view CraigH98's profile Novice 6 posts since
Oct 12, 2005

I'm trying to determine the networks available to vm's in my cluster. If I run a powershell script with this in it...

Connect-VIServer ServerName

$net = Get-NetworkAdapter -VM "TestVM"
echo $net

MacAddress : 00:50:56:88:02:ed
WakeOnLanEnabled : True
NetworkName : Network1
Type : Flexible
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
Id : VirtualMachine-vm-594/4000
Name : Network Adapter 1

MacAddress : 00:50:56:98:46:18
WakeOnLanEnabled : True
NetworkName : Network2
Type : Flexible
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
Id : VirtualMachine-vm-594/4001
Name : Network Adapter 2

My question is, how can I input the value of NetworkName into a variable so that I can do a comparison? Or is there a better way to get the values of NetworkName?

Re: Identifying networks available to VM's

1. Jun 2, 2009 8:39 AM in response to: CraigH98
Click to view alanrenouf's profile Master vExpert 623 posts since
Feb 28, 2006

If your just trying to output the network adapters attached to your vms then using your current script you could do this:

$net = Get-NetworkAdapter -VM "vpedhcp01"
foreach ($networkadapter in $net) {echo $networkadapter.NetworkName}

Are you trying to list each VM in a cluster and then the networks attached to the VM, if so this is fairly easy too?

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf
http://virtu-al.net

Re: Identifying networks available to VM's

2. Jun 2, 2009 8:40 AM in response to: CraigH98
Click to view yboychev's profile Hot Shot VMware Employees 75 posts since
Mar 5, 2008

I can't really get your question but hope this helps:

$networkName = "Network1"

$net = Get-NeetworkAdapter -Vm "TestVm" | where {$_.NetworkName -eq $networkName}


VMware Beta Programs

Want to be Considered for Future Beta Programs?

Learn More

VMware Developer

Download SDKs, APIs, videos,
training, and more in the Developer community.

Learn More

Developer
Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld
Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

Only VMware ... Delivers Nexus 1000V

Ensure consistent, policy-based network capabilities to virtual machines across your data center.

Learn More

Communities