«

»

Dec 21 2011

Change virtual machines network adapter using PowerCLI

A few times in my network I had to change the virtual adapter for over 500 VMs. Because a manual configuration of those VMs was not a solution, I turned to PowerCLI. To start open you PowerCLI console and connect to your vCenter Server.

One way of doing this:

In this example the script will change the network adapter for all the VMs that resides in your vCenter Infrastrucutre. The  $vm = get-vm command reads all the VMs in the infrastrucutre and puts them in a variable. The  $newnet = “VM Network – 192.168.100.x” puts the new network adapter in a variable. The last line  get-vm $vm | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $newnet assigns the new network adapter to all the VMs in the variable $vm.

Off course you can be more granular and change the network only to the VMs that resides on one, or a couple of ESX Servers, not the entire infrastructure.

 

Another way of doing this:

 

This script will change the network adapter to all the VMs in your vCenter infrastructure that are connected to VM Network-172.x.



Want content like this delivered right to your

email inbox?


2 comments

  1. Akila

    can anyone help me the commands with add an existing VM (on esxi)to network ? and how to find the network info of esxi?

  2. David Christie

    Great informative post. Many thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

css.php