<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: dvSwitch scripting – Part 4 – NIC teaming	</title>
	<atom:link href="https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Mon, 11 Jun 2012 06:55:57 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.9</generator>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>
		By: Sven		</title>
		<link>https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/#comment-1627</link>

		<dc:creator><![CDATA[Sven]]></dc:creator>
		<pubDate>Mon, 11 Jun 2012 06:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://lucd.info/?p=788#comment-1627</guid>

					<description><![CDATA[&lt;a href=&quot;#comment-1615&quot; rel=&quot;nofollow&quot;&gt;@Sven &lt;/a&gt; 
Okay, I think i finally made it.

I just didn&#039;t realized, that the physical NICs had to be free before i can connect them.
So I had to remove them from the VSS before connectim them to the dvSwitch.
I removed all NICs from all VSS with the following line.
$vmhostview.config.network.vswitch &#124; %{ Get-Virtualswitch -ID $_.key -VMHost $vmhost &#124; Set-VirtualSwitch -Nic @() -Confirm:$false &#124; Out-Null}]]></description>
			<content:encoded><![CDATA[<p><a href="#comment-1615" rel="nofollow">@Sven </a><br />
Okay, I think i finally made it.</p>
<p>I just didn&#8217;t realized, that the physical NICs had to be free before i can connect them.<br />
So I had to remove them from the VSS before connectim them to the dvSwitch.<br />
I removed all NICs from all VSS with the following line.<br />
$vmhostview.config.network.vswitch | %{ Get-Virtualswitch -ID $_.key -VMHost $vmhost | Set-VirtualSwitch -Nic @() -Confirm:$false | Out-Null}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sven		</title>
		<link>https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/#comment-1615</link>

		<dc:creator><![CDATA[Sven]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 12:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://lucd.info/?p=788#comment-1615</guid>

					<description><![CDATA[Hi,
At first I really want to thank you for your work on the DVSwitch functions, which were really helpfully for my work.

At the Moment I am working on a longer script, which will automate our whole ESXi Configuration.

Therefore I used some of your functions and edited them to my needs.

For now I have written a huge function which joins the new Host to the DVswitch.
It consists of the following steps:
-Check for NICs which can be connected to the dVSwitch without loosing connection
-Connect them to the dvSwitch
-Migrate the Management vmk Adapter to the appropriat PortGroup on the dvSwitch
-Migrate all other existing vmKs 
-Migrate all VMs
-Now add the NICs connected to the VSS to the dvSwitch

The last step, it is, that I can&#039;t get to manage..
I&#039;ve copied your Add-dvSwHostpNic function and changed some little things..
But when I call it I alway get &quot;A parameter specified was not correct&quot;

This is how my function looks like:
function  Add-dvSwHostpNic{
param ($dvSw,$vmhost, $pnics)
$dvSw.UpdateviewData()
#changed this to support VMware.Vim.PhysicalNic Objects
if(($pnics &#124; ? {$_.Device})){$pnics = $pnics &#124; % {$_.Device}}
#changed this to connect only the choosen hosts nics
$dvSw.Config.Host &#124; Where {(Get-VMHost -ID $_.Config.Host).Name -eq $vmhost} &#124; % {

$hostNetSys = Get-View (Get-View $_.Config.Host).configManager.networkSystem
$spec = New-Object VMware.Vim.HostNetworkConfig
$pSwitch = New-Object VMware.Vim.HostProxySwitchConfig
$pSwitch.changeOperation = &quot;edit&quot;
$pSwitch.spec = New-Object VMware.Vim.HostProxySwitchSpec

$pSwitch.spec.backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking

# Get available Uplinks

$hostNetSys.NetworkInfo.ProxySwitch &#124; where {$_.DvsName -eq $dvSw.Name} &#124; % {
$configuredUplinks = @{}
$_.UplinkPort &#124; % {$configuredUplinks[$_.Key] = $_.Value}
$_.Spec.Backing.PnicSpec &#124; % {
$configuredUplinks.Remove($_.UplinkPortKey)
$pSwitch.spec.backing.pnicSpec += $_
}
}

# Assign the free uplinks to the new pNics
$i = 0
#important to be an array
$keysUplinks = [System.Array]($configuredUplinks.Keys &#124; Sort-Object)
$pnics &#124; % {
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec
$pnic.pnicDevice = $_
$pnic.UplinkPortKey = $keysUplinks[$i]
$i++
$pSwitch.spec.backing.pnicSpec += $pnic
}
$pSwitch.uuid = $dvSw.Config.Uuid
$spec.ProxySwitch = $pSwitch
$result = $hostNetSys.UpdateNetworkConfig($spec, &quot;modify&quot;)
}
}


And this is the way I call it:
$vds = &quot;ESXCluster_dvswitch01&quot; #thats the name of the dvSwitch
$vmhost = &quot;esxi02.test.local&quot; #thats the name of the Esxi Host.
#vmnic1 is already connected 
#vmnic0 is connected to vswitch0 of the Host
$connected_nics = @(&quot;vmnic0&quot;)
add-dvSwHostpNic (Get-Virtualswitch -Distributed -Name $vds &#124; Get-View) $vmhost $connected_nics

I debugged the script for a long time now... 
So I hoped anybody here could help me?

Sorry for the poor english.

Greetings from Germany
Sven]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
At first I really want to thank you for your work on the DVSwitch functions, which were really helpfully for my work.</p>
<p>At the Moment I am working on a longer script, which will automate our whole ESXi Configuration.</p>
<p>Therefore I used some of your functions and edited them to my needs.</p>
<p>For now I have written a huge function which joins the new Host to the DVswitch.<br />
It consists of the following steps:<br />
-Check for NICs which can be connected to the dVSwitch without loosing connection<br />
-Connect them to the dvSwitch<br />
-Migrate the Management vmk Adapter to the appropriat PortGroup on the dvSwitch<br />
-Migrate all other existing vmKs<br />
-Migrate all VMs<br />
-Now add the NICs connected to the VSS to the dvSwitch</p>
<p>The last step, it is, that I can&#8217;t get to manage..<br />
I&#8217;ve copied your Add-dvSwHostpNic function and changed some little things..<br />
But when I call it I alway get &#8220;A parameter specified was not correct&#8221;</p>
<p>This is how my function looks like:<br />
function  Add-dvSwHostpNic{<br />
param ($dvSw,$vmhost, $pnics)<br />
$dvSw.UpdateviewData()<br />
#changed this to support VMware.Vim.PhysicalNic Objects<br />
if(($pnics | ? {$_.Device})){$pnics = $pnics | % {$_.Device}}<br />
#changed this to connect only the choosen hosts nics<br />
$dvSw.Config.Host | Where {(Get-VMHost -ID $_.Config.Host).Name -eq $vmhost} | % {</p>
<p>$hostNetSys = Get-View (Get-View $_.Config.Host).configManager.networkSystem<br />
$spec = New-Object VMware.Vim.HostNetworkConfig<br />
$pSwitch = New-Object VMware.Vim.HostProxySwitchConfig<br />
$pSwitch.changeOperation = &#8220;edit&#8221;<br />
$pSwitch.spec = New-Object VMware.Vim.HostProxySwitchSpec</p>
<p>$pSwitch.spec.backing = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicBacking</p>
<p># Get available Uplinks</p>
<p>$hostNetSys.NetworkInfo.ProxySwitch | where {$_.DvsName -eq $dvSw.Name} | % {<br />
$configuredUplinks = @{}<br />
$_.UplinkPort | % {$configuredUplinks[$_.Key] = $_.Value}<br />
$_.Spec.Backing.PnicSpec | % {<br />
$configuredUplinks.Remove($_.UplinkPortKey)<br />
$pSwitch.spec.backing.pnicSpec += $_<br />
}<br />
}</p>
<p># Assign the free uplinks to the new pNics<br />
$i = 0<br />
#important to be an array<br />
$keysUplinks = [System.Array]($configuredUplinks.Keys | Sort-Object)<br />
$pnics | % {<br />
$pnic = New-Object VMware.Vim.DistributedVirtualSwitchHostMemberPnicSpec<br />
$pnic.pnicDevice = $_<br />
$pnic.UplinkPortKey = $keysUplinks[$i]<br />
$i++<br />
$pSwitch.spec.backing.pnicSpec += $pnic<br />
}<br />
$pSwitch.uuid = $dvSw.Config.Uuid<br />
$spec.ProxySwitch = $pSwitch<br />
$result = $hostNetSys.UpdateNetworkConfig($spec, &#8220;modify&#8221;)<br />
}<br />
}</p>
<p>And this is the way I call it:<br />
$vds = &#8220;ESXCluster_dvswitch01&#8221; #thats the name of the dvSwitch<br />
$vmhost = &#8220;esxi02.test.local&#8221; #thats the name of the Esxi Host.<br />
#vmnic1 is already connected<br />
#vmnic0 is connected to vswitch0 of the Host<br />
$connected_nics = @(&#8220;vmnic0&#8221;)<br />
add-dvSwHostpNic (Get-Virtualswitch -Distributed -Name $vds | Get-View) $vmhost $connected_nics</p>
<p>I debugged the script for a long time now&#8230;<br />
So I hoped anybody here could help me?</p>
<p>Sorry for the poor english.</p>
<p>Greetings from Germany<br />
Sven</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/#comment-1577</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Fri, 18 May 2012 11:20:34 +0000</pubDate>
		<guid isPermaLink="false">http://lucd.info/?p=788#comment-1577</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/#comment-1574&quot;&gt;Mike Schubert&lt;/a&gt;.

Hi Mike, to avoid concurrent updates to a dvSwitch, one has to use the configVersion property (line 13).
Strange you are getting that error.
Could you perhaps set the vCenter logging temporary to &quot;Verbose&quot; and see if that perhaps gives a bit clues what goes wrong.
Feel free to send me an extract of the verbose log (lucd (at) lucd (dot) info)]]></description>
			<content:encoded><![CDATA[<p>Hi Mike, to avoid concurrent updates to a dvSwitch, one has to use the configVersion property (line 13).<br />
Strange you are getting that error.<br />
Could you perhaps set the vCenter logging temporary to &#8220;Verbose&#8221; and see if that perhaps gives a bit clues what goes wrong.<br />
Feel free to send me an extract of the verbose log (lucd (at) lucd (dot) info)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Mike Schubert		</title>
		<link>https://www.lucd.info/2009/10/27/dvswitch-scripting-part-4-nic-teaming/#comment-1574</link>

		<dc:creator><![CDATA[Mike Schubert]]></dc:creator>
		<pubDate>Fri, 18 May 2012 09:10:49 +0000</pubDate>
		<guid isPermaLink="false">http://lucd.info/?p=788#comment-1574</guid>

					<description><![CDATA[Hello,

all of this function around DVSwitches are great.
Currently i have some problems using function Set-dVSwPgTeam.

The ReconfigureDVPortgroup_Task returns no errors but i see some failures in vCenter logging.
&quot;Cannot complete operation due to concurrent modification by another operation.&quot;

I use a 5U1 Environment with Version 5 DV Switch.

Has anybody some ideas why this error occurs?

best regards,
Mike

But there is no other operation on the DV Switch.]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>all of this function around DVSwitches are great.<br />
Currently i have some problems using function Set-dVSwPgTeam.</p>
<p>The ReconfigureDVPortgroup_Task returns no errors but i see some failures in vCenter logging.<br />
&#8220;Cannot complete operation due to concurrent modification by another operation.&#8221;</p>
<p>I use a 5U1 Environment with Version 5 DV Switch.</p>
<p>Has anybody some ideas why this error occurs?</p>
<p>best regards,<br />
Mike</p>
<p>But there is no other operation on the DV Switch.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
