#----------------- Start of code capture ----------------- #---------------QueryAvailableDvsSpec--------------- $recommended = $true $_this = Get-View -Id 'DistributedVirtualSwitchManager-DVSManager' $_this.QueryAvailableDvsSpec($recommended) #---------------QueryAvailableDvsSpec--------------- $recommended = $true $_this = Get-View -Id 'DistributedVirtualSwitchManager-DVSManager' $_this.QueryAvailableDvsSpec($recommended) #---------------QueryDvsCheckCompatibility--------------- $hostContainer = New-Object VMware.Vim.DistributedVirtualSwitchManagerHostContainer $hostContainer.Container = New-Object VMware.Vim.ManagedObjectReference $hostContainer.Container.Type = 'Datacenter' $hostContainer.Container.Value = 'datacenter-2251' $hostContainer.Recursive = $true $dvsProductSpec = New-Object VMware.Vim.DistributedVirtualSwitchManagerDvsProductSpec $dvsProductSpec.NewSwitchProductSpec = New-Object VMware.Vim.DistributedVirtualSwitchProductSpec $dvsProductSpec.NewSwitchProductSpec.ForwardingClass = 'cswitch' $dvsProductSpec.NewSwitchProductSpec.Build = '00000' $dvsProductSpec.NewSwitchProductSpec.Vendor = 'VMware, Inc.' $dvsProductSpec.NewSwitchProductSpec.Name = 'DVS' $dvsProductSpec.NewSwitchProductSpec.Version = '7.0.0' $hostFilterSpec = New-Object VMware.Vim.DistributedVirtualSwitchManagerHostDvsFilterSpec[] (1) $hostFilterSpec[0] = New-Object VMware.Vim.DistributedVirtualSwitchManagerHostContainerFilter $hostFilterSpec[0].HostContainer = New-Object VMware.Vim.DistributedVirtualSwitchManagerHostContainer $hostFilterSpec[0].HostContainer.Container = New-Object VMware.Vim.ManagedObjectReference $hostFilterSpec[0].HostContainer.Container.Type = 'Datacenter' $hostFilterSpec[0].HostContainer.Container.Value = 'datacenter-2251' $hostFilterSpec[0].HostContainer.Recursive = $true $hostFilterSpec[0].Inclusive = $true $_this = Get-View -Id 'DistributedVirtualSwitchManager-DVSManager' $_this.QueryDvsCheckCompatibility($hostContainer, $dvsProductSpec, $hostFilterSpec) #---------------QueryCompatibleHostForExistingDvs--------------- $container = New-Object VMware.Vim.ManagedObjectReference $container.Type = 'Datacenter' $container.Value = 'datacenter-2251' $recursive = $true $dvs = New-Object VMware.Vim.ManagedObjectReference $dvs.Type = 'VmwareDistributedVirtualSwitch' $dvs.Value = 'dvs-2267' $_this = Get-View -Id 'DistributedVirtualSwitchManager-DVSManager' $_this.QueryCompatibleHostForExistingDvs($container, $recursive, $dvs) #---------------ReconfigureDvs_Task--------------- $spec = New-Object VMware.Vim.DVSConfigSpec $spec.ConfigVersion = '17' $spec.Host = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberConfigSpec[] (1) $spec.Host[0] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberConfigSpec $spec.Host[0].Host = New-Object VMware.Vim.ManagedObjectReference $spec.Host[0].Host.Type = 'HostSystem' $spec.Host[0].Host.Value = 'host-2264' $spec.Host[0].Operation = 'add' $_this = Get-View -Id 'VmwareDistributedVirtualSwitch-dvs-2267' $_this.ReconfigureDvs_Task($spec) #---------------FetchDVPorts--------------- $criteria = New-Object VMware.Vim.DistributedVirtualSwitchPortCriteria $criteria.UplinkPort = $true $_this = Get-View -Id 'VmwareDistributedVirtualSwitch-dvs-2267' $_this.FetchDVPorts($criteria) #---------------UpdateNetworkConfig--------------- $config = New-Object VMware.Vim.HostNetworkConfig $config.Vswitch = New-Object VMware.Vim.HostVirtualSwitchConfig[] (1) $config.Vswitch[0] = New-Object VMware.Vim.HostVirtualSwitchConfig $config.Vswitch[0].Name = 'vSwitch0' $config.Vswitch[0].ChangeOperation = 'edit' $config.Vswitch[0].Spec = New-Object VMware.Vim.HostVirtualSwitchSpec $config.Vswitch[0].Spec.NumPorts = 128 $config.Vswitch[0].Spec.Policy = New-Object VMware.Vim.HostNetworkPolicy $config.Vswitch[0].Spec.Policy.Security = New-Object VMware.Vim.HostNetworkSecurityPolicy $config.Vswitch[0].Spec.Policy.Security.AllowPromiscuous = $false $config.Vswitch[0].Spec.Policy.Security.ForgedTransmits = $false $config.Vswitch[0].Spec.Policy.Security.MacChanges = $false $config.Vswitch[0].Spec.Policy.OffloadPolicy = New-Object VMware.Vim.HostNetOffloadCapabilities $config.Vswitch[0].Spec.Policy.OffloadPolicy.TcpSegmentation = $true $config.Vswitch[0].Spec.Policy.OffloadPolicy.ZeroCopyXmit = $true $config.Vswitch[0].Spec.Policy.OffloadPolicy.CsumOffload = $true $config.Vswitch[0].Spec.Policy.ShapingPolicy = New-Object VMware.Vim.HostNetworkTrafficShapingPolicy $config.Vswitch[0].Spec.Policy.ShapingPolicy.Enabled = $false $config.Vswitch[0].Spec.Policy.NicTeaming = New-Object VMware.Vim.HostNicTeamingPolicy $config.Vswitch[0].Spec.Policy.NicTeaming.NotifySwitches = $true $config.Vswitch[0].Spec.Policy.NicTeaming.RollingOrder = $false $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria = New-Object VMware.Vim.HostNicFailureCriteria $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.FullDuplex = $false $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.Percentage = 0 $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.CheckErrorPercent = $false $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.CheckDuplex = $false $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.CheckBeacon = $false $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.Speed = 10 $config.Vswitch[0].Spec.Policy.NicTeaming.FailureCriteria.CheckSpeed = 'minimum' $config.Vswitch[0].Spec.Policy.NicTeaming.Policy = 'loadbalance_srcid' $config.Vswitch[0].Spec.Policy.NicTeaming.ReversePolicy = $true $config.Portgroup = New-Object VMware.Vim.HostPortGroupConfig[] (1) $config.Portgroup[0] = New-Object VMware.Vim.HostPortGroupConfig $config.Portgroup[0].ChangeOperation = 'remove' $config.Portgroup[0].Spec = New-Object VMware.Vim.HostPortGroupSpec $config.Portgroup[0].Spec.VswitchName = '' $config.Portgroup[0].Spec.VlanId = -1 $config.Portgroup[0].Spec.Name = 'Management Network' $config.Portgroup[0].Spec.Policy = New-Object VMware.Vim.HostNetworkPolicy $config.Vnic = New-Object VMware.Vim.HostVirtualNicConfig[] (1) $config.Vnic[0] = New-Object VMware.Vim.HostVirtualNicConfig $config.Vnic[0].Portgroup = '' $config.Vnic[0].Device = 'vmk0' $config.Vnic[0].ChangeOperation = 'edit' $config.Vnic[0].Spec = New-Object VMware.Vim.HostVirtualNicSpec $config.Vnic[0].Spec.DistributedVirtualPort = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection $config.Vnic[0].Spec.DistributedVirtualPort.SwitchUuid = '50 09 85 33 ea 23 be 5e-58 75 9f 7d 98 09 ef 73' $config.Vnic[0].Spec.DistributedVirtualPort.PortgroupKey = 'dvportgroup-2269' $config.ProxySwitch = New-Object VMware.Vim.HostProxySwitchConfig[] (1) $config.ProxySwitch[0] = New-Object VMware.Vim.HostProxySwitchConfig $config.ProxySwitch[0].Uuid = '50 09 85 33 ea 23 be 5e-58 75 9f 7d 98 09 ef 73' $config.ProxySwitch[0].ChangeOperation = 'edit' $config.ProxySwitch[0].Spec = New-Object VMware.Vim.HostProxySwitchSpec $config.ProxySwitch[0].Spec.Backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking $config.ProxySwitch[0].Spec.Backing.PnicSpec = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec[] (2) $config.ProxySwitch[0].Spec.Backing.PnicSpec[0] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec $config.ProxySwitch[0].Spec.Backing.PnicSpec[0].PnicDevice = 'vmnic0' $config.ProxySwitch[0].Spec.Backing.PnicSpec[0].UplinkPortKey = '390' $config.ProxySwitch[0].Spec.Backing.PnicSpec[0].UplinkPortgroupKey = 'dvportgroup-2268' $config.ProxySwitch[0].Spec.Backing.PnicSpec[1] = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec $config.ProxySwitch[0].Spec.Backing.PnicSpec[1].PnicDevice = 'vmnic1' $config.ProxySwitch[0].Spec.Backing.PnicSpec[1].UplinkPortKey = '391' $config.ProxySwitch[0].Spec.Backing.PnicSpec[1].UplinkPortgroupKey = 'dvportgroup-2268' $changeMode = 'modify' $_this = Get-View -Id 'HostNetworkSystem-networkSystem-2264' $_this.UpdateNetworkConfig($config, $changeMode) #---------------QueryAvailableDvsSpec--------------- $recommended = $true $_this = Get-View -Id 'DistributedVirtualSwitchManager-DVSManager' $_this.QueryAvailableDvsSpec($recommended) #----------------- End of code capture ----------------- |