Hello at all,
i try to use VI Toolkit 4 Win.
When i use Get-VirtualSwitch, i receive anly 1 info, but my VM have 3 Network.
Example:
$MyVC = Get-VC <myserver>
$MyVM = Ge-VM "VIRTUALCENTER"
Get-NetworkAdapter $MyVM
MacAddress : 00:50:56:a9:73:8c
WakeOnLanEnabled : False
NetworkName : Lan0
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
ID : VirtualMachine-vm-1442/4000
Name : Network Adapter 1
MacAddress : 00:50:56:a9:67:c4
WakeOnLanEnabled : False
NetworkName : Isolate0 TAG
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
ID : VirtualMachine-vm-1442/4001
Name : Network Adapter 2
MacAddress : 00:0c:29:ca:f5:13
WakeOnLanEnabled : True
NetworkName : Isolate0
ConnectionState : VMware.VimAutomation.Client20.ConnectInfoImpl
ID : VirtualMachine-vm-1442/4002
Name : Network Adapter 3
Get-VirtualSwitch -VM $MyVM
vSwitch0 32 22 0 key-vim.host.VirtualSwitch-...
Moreover, how can I have the association PortGroup on vSwitch?
Thanks to all
BigMax
Do you want to use Get-VMHostNetwork rather than Get-VirtualSwitch?
Hello c_shanklin,
thanks, but i need to found VirtualMachine VNetCard -> PortGroup -> VirtualSwitch -> Physical NetCard.
Example:
VM FreeSCO with 2 VNetCard, 1 on PortGroup LAN0 on vSwitch1 on Physical NetCard vmnic0, 1 on PortGroup DMZ0 on vSwitch2 on Physical NetCard vmnic1.
I have found associaton with VNetCard -> PortGroup and association with VirtualSwitch -> Physical NetCard, but no PortGroup -> VirtualSwitch.
The command Get-VirtualSwitch, as described in the 'help, should see a list of VirtualSwitch used by a VM, but always displays only the first.
The command Get-VMHostNetwork Instead, always return the full networking by Host, but no portgroup.
To get the link vNic - Portgroup - vSwitch - pNIC one has to revert to the SDK.
This script is a quick and dirty attempt to list this link for all guests.
Get-VM | %{Get-View $_.ID} | %{ write-host "VM : " $_.Name foreach($nicImpl in $_.Network){ $nic = Get-View $nicImpl Write-Host "Portgroup : " $nic.Name $esx = Get-View $nic.Host[0] foreach($hnet in $esx.Config.Network.Portgroup){ <b>if</b>($hnet.Spec.Name -eq $nic.Name){ Write-Host "vSwitch : " $hnet.Spec.VswitchName <b>if</b>($hnet.ComputedPolicy.NicTeaming.NicOrder.ActiveNic -is [array]){ foreach($pnic in $hnet.ComputedPolicy.NicTeaming.NicOrder.ActiveNic){ Write-Host "pNIC : " $pnic } } } } } }
Since a portgroup can be defined on multiple ESX servers (clustering) I use by default the first ESX server to get at the portgroup and pNICs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD,
thanks for replay.
I test your script, but always i receive a "MoRef is null".
I try this:
Get-vc <myserver>
$MyVM = Get-VM VirtualCenter
$MyView1 = Get-View $MyVM.ID
Get-View $MyView1.Network generate error MoRef is null
$MyView1.Name is empty.
I'm something wrong?
Thanks
Are you testing this from within the PowerShellPlus editor ?
Can you stop/start your PowerShellPlus session and try again.
Or test under a "VMware VI Toolkit (for Windows)" session.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
i test in VMWare VI Toolkit (For WIndows) session (ps1 file), but receive error.
When i test on PowerGUI script editor, script work!
Thanks 4 help.
Did you also try after a stop/start of the "VMware VI Toolkit (For Windows)" session ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
oops, my bad.
I Stop and start session and ... ok, all work.
Thanks.