i am trying to add a vmnic to vswitch0 , which is the management switch using the following
$vs = Get-virtualSwitch -Name Vswitch0 -VMHOST (Get-VMHOST 10.4.50.200)
Set-VirtualSwitch -virtualswitch vswitch0 -Nic Vmnic3
but i think the whole syntax is wrong can someone point me in the right direction
thanks
Nearly correct, the -VirtualSwitch parameter in the Set-VirtualSwitch cmdlet should be a VirtualSwitchImpl object.
You should have done
$vs = Get-virtualSwitch -Name Vswitch0 -VMHOST (Get-VMHOST 10.4.50.200) Set-VirtualSwitch -virtualswitch $vs -Nic Vmnic3
Or by using the pipeline
Get-virtualSwitch -Name Vswitch0 -VMHOST (Get-VMHOST 10.4.50.200) | Set-VirtualSwitch -Nic Vmnic3
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
when i run the above line i get the following
Set-VirtualSwitch : 22/09/2009 09:47:29 Set-VirtualSwitch 52a469d4-6ed9-d
a28-6fa2-c3d0e1502a6d The object or item referred to could not be found.
At C:\vmlog\vhsp0019.ps1:86 char:87
+ Get-virtualSwitch -Name Vswitch0 -VMHOST (Get-VMHOST 10.72.107.38) | Set-Virt
ualSwitch <<<< -Nic Vmnic3
does the error means it canot find Vswitch0 ??
thanks
No, it probably means that the name of the NIC was not correct.
Note that these names are case-sensitive.
It should probably be
$vs = Get-virtualSwitch -Name Vswitch0 -VMHOST (Get-VMHOST 10.4.50.200) Set-VirtualSwitch -virtualswitch $vs -Nic vmnic3
Which is strange because this is apparently not the case for he vSwitch name (which is most probably vSwitch0).
A feature of the cmdlet ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi
thanks its working now ,need to pay more attention to case
thanks
A word to some; make sure that you also include any other NIC that you already have added on the vSwitch or you may lose networking :smileylaugh:
I had vSwitch0 with VMNIC0 in use already and ran:
Get-VirtualSwitch -Name vSwitch0 -VMHost $esxiHost | Set-VirtualSwitch -Nic vmnic1 -Confirm:$false
... then I lost connectivity to the host as it overwrote the configuration.
To perform it correctly I used:
Get-VirtualSwitch -Name vSwitch0 -VMHost $esxiHost | Set-VirtualSwitch -Nic vmnic0,vmnic1 -Confirm:$false