VMware Cloud Community
chakoe
Enthusiast
Enthusiast

add a pyhsical NIC to a vSwitch, but do not replace the existing

Hi,

i need a scripts to do things described in the title...i want to add a physical NIC to an existing vSwitch without replacing

the existing/configured NIC in the vSwitch...

My actual script looks like this:

$vs =Get-VirtualSwitch -VMHost $vmHost -Name vSwitch0
$vs | Set-VirtualSwitch -Nic vmnic1

This one replaces the existing NIC 😞

Any idea?

Thx in advance!

Chakoe

0 Kudos
23 Replies
RvdNieuwendijk
Leadership
Leadership

Hi Chakoe,

You can add a nic to a switch with:

$vs =Get-VirtualSwitch -VMHost $vmHost -Name vSwitch0
$nic = $vs.Nic + "vmnic1"
$vs | Set-VirtualSwitch -Nic $nic

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

Although there are some problem when you use Set-VirtualSwitch in a pipeline, you can still make this a one-liner (with a bit of trickery).

Get-VirtualSwitch -Name vSwitch0 -VMHost $vmHost | %{Set-VirtualSwitch -VirtualSwitch $_ -Nic (&{$_.Nic + "vmnic1"})}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

my script now works fine so far...but i found another question...we operate our ESX - vSwitches in an Active / Passive config..

How do I have to modify my script to set the vmnic0 & vmnic2 to active and vmnic1 & vmnic3 to passive?

This is my actual script:

Connect-VIServer "virtualcenter"
$vmHost = Get-VMHost Host1 | Sort-Object {$_.Name}

# Add another COS-NIC
Get-VirtualSwitch -Name vSwitch0 -VMHost $vmHost | %{Set-VirtualSwitch -VirtualSwitch $_ -Nic (&{$_.Nic + "vmnic1"})}

# Add first NIC to VM-Network-VSwitch
Get-VirtualSwitch -Name vSwitch1 -VMHost $vmHost | Set-VirtualSwitch -Nic "vmnic2"

# Add second NIC to VM-Network-VSwitch
Get-VirtualSwitch -Name vSwitch1 -VMHost $vmHost | %{Set-VirtualSwitch -VirtualSwitch $_ -Nic (&{$_.Nic + "vmnic3"})}

Thx in advance

Chakoe

0 Kudos
LucD
Leadership
Leadership

You can use the Set-NicTeamingPolicy cmdlet for that.

Get-VirtualSwitch -Name vSwitch0 -VMHost $vmHost |  Get-NicTeamingPolicy | Set-NicTeaminPolicy -MakeNicActive "vmnic0","vmnic2" -MakeNicStandby "vmnic1","vmnic3"



Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

my script works fine right now!

THANKS!

But:

Does anyone if you can use PowerCLI to stage an Remediate the Host as you can do it in VSphereClient ( Host Update Manager)?

0 Kudos
LucD
Leadership
Leadership

Yes you can. Use the Update Manager snapin.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

I tried to download

vCenter Update Manager PowerCLI Version 4.1

Error is: Invalid Download Group

vCenter Update Manager PowerCLI Version 4.0 U1

I can´t install this version, error is ( simplified): PowerCLI 4.0 or earlier needed...

I´ve installed PowerCLI 4.1.1 on my machine........

Where can i find the download for Snapin 4.1?

0 Kudos
LucD
Leadership
Leadership

I get the same error, must be something wrong with the link to the repository.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RvdNieuwendijk
Leadership
Leadership

You will need version 4.1. But there seems to be something wrong on the VMware download server now. It has worked well before.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

VMW is looking into it.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
chakoe
Enthusiast
Enthusiast

Good morning,

not fixed so far... 😞

wait wait 🙂

0 Kudos
RvdNieuwendijk
Leadership
Leadership

If you send me a private mail with your e-mail address, I will put the VMware vCenter Update Manager PowerCLI 4.1 installation kit in my DropBox for you (See: www.dropbox.com).

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

same error message:

Incombatible Versio ov Power CLI, PowerCLI 4.0 or later is needed....

But it is installed....install Package was VMware-PowerCLI-4.1.1-332441.exe

What´s going wrong here?

0 Kudos
RvdNieuwendijk
Leadership
Leadership

What output do you get from the Get-PowerCLIVersion cmdlet? You should get:

PowerCLI Version
----------------
   VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
   VMWare vSphere PowerCLI 4.1 U1 build 332441
   VMware vCenter Update Manager PowerCLI 4.1 build 266648

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi,

output is:

PowerCLI Version
----------------
   VMware vSphere PowerCLI 4.1 U1 build 332441
---------------
Snapin Versions
---------------
   VMWare vSphere PowerCLI 4.1 U1 build 332441

0 Kudos
RvdNieuwendijk
Leadership
Leadership

So your PowerCLI version is the latest. If I install the VMware Update Manager PowerCLI package from the DropBox (VMware-UpdateManager-Pscli-4.1.0-266648.exe) again and do a repair I have no problems

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi Robert,

i just rebootet my Notebook ( W XP SP3 )...same problem.

Is there another Chance? Can i get the extracted MSI-Packet? Or is there a chance

to manually register the needed files?

0 Kudos
RvdNieuwendijk
Leadership
Leadership

I have installed VMware vCenter Update Manager PowerCLI 4.1 on a Windows XP Sp3 PC without any problem. Maybe there is something wrong with your PowerCLI installation? Can you try to first deinstall VMware vSphere PowerCLI and VMware VIX and then install PowerCLI 4.1U1 again? I hope the installation of VMware vCenter Update Manager PowerCLI 4.1 will succeed after this.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi Robert,

mysterious mysterious 🙂 but after many uninstalls and installs it worked 🙂

0 Kudos