<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PeetersOnline &#187; vSwitch</title>
	<atom:link href="http://www.peetersonline.nl/index.php/tag/vswitch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peetersonline.nl</link>
	<description>Using Powershell for (virtually) everything!</description>
	<lastBuildDate>Fri, 19 Aug 2011 09:22:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Create a vSwitch Port Overview with Powershell</title>
		<link>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/</link>
		<comments>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 10:42:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PowerCLI 4.0]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[vSwitch]]></category>

		<guid isPermaLink="false">http://www.peetersonline.nl/?p=404</guid>
		<description><![CDATA[WARNING: VMware vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in this KB article. The solution to <a href='http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/'>[...]</a>
Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>WARNING: <a href="http://www.vmware.com/" target='_blank'>VMware</a> vmotion does not check wether there are sufficient ports available on the virtual switch on the destination host. Migrating a vm to a host with insufficient ports will cause the vmotion to complete without warnings, yet the virtual NIC will be disconnected! This issue is descripbed in <a href="http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&#038;docType=kc&#038;externalId=1009103&#038;sliceId=1&#038;docTypeID=DT_KB_1_1&#038;dialogID=26680233&#038;stateId=1%200%2026678654">this KB article</a>.<br />
The solution to this problem is to create vSwitches with sufficient ports, obviously. Do you want to know how many ports are currently being used on every vSwitch in your environment? <a href="http://www.vmware.com/products/vsphere/" target='_blank'>vSphere</a> <a href="http://communities.vmware.com/community/developer/windows_toolkit" target='_blank'>PowerCLI</a> to the rescue! Try the following script:</p>
<p><span id="more-404"></span></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$VC</span> <span style="color: pink;">=</span> Connect<span style="color: pink;">-</span>VIServer <span style="color: #800000;">&quot;MyVCServer&quot;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
	<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VM</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$VMHost</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>VM<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$NIC</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>NetworkAdapter <span style="color: pink;">-</span>VM <span style="color: #800080;">$VM</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
			<span style="color: #800080;">$myObj</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;&quot;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> VMHost<span style="color: pink;">,</span> VM<span style="color: pink;">,</span> NIC<span style="color: pink;">,</span> PortGroup<span style="color: pink;">,</span> vSwitch
			<span style="color: #800080;">$myObj</span>.VMHost <span style="color: pink;">=</span> <span style="color: #800080;">$VMHost</span>.Name
			<span style="color: #800080;">$myObj</span>.VM <span style="color: pink;">=</span> <span style="color: #800080;">$VM</span>.Name
			<span style="color: #800080;">$myObj</span>.NIC <span style="color: pink;">=</span> <span style="color: #800080;">$NIC</span>.Name
			<span style="color: #800080;">$myObj</span>.PortGroup <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VirtualPortGroup <span style="color: pink;">-</span>VM <span style="color: #800080;">$VM</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$NIC</span>.NetworkName
			<span style="color: #800080;">$myObj</span>.vSwitch <span style="color: pink;">=</span> <span style="color: #800080;">$myObj</span>.PortGroup.VirtualSwitchName
			<span style="color: #800080;">$myCol</span> <span style="color: pink;">+=</span> <span style="color: #800080;">$myObj</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$myCol</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Group-Object</span> VMHost<span style="color: pink;">,</span> vSwitch <span style="color: #008080; font-style: italic;">-NoElement</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort</span> Name <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Select</span> Name<span style="color: pink;">,</span> Count
Disconnect<span style="color: pink;">-</span>VIServer <span style="color: #008080; font-style: italic;">-Confirm</span>:$false</pre></div></div>

<p>Related posts:<ol>
<li><a href='http://www.peetersonline.nl/index.php/vmware/calculate-vsphere-5-licenses-with-powershell/' rel='bookmark' title='Calculate vSphere 5 Licenses with Powershell (UPDATED)'>Calculate vSphere 5 Licenses with Powershell (UPDATED)</a></li>
<li><a href='http://www.peetersonline.nl/index.php/vmware/remove-vmware-memory-limits-with-powershell/' rel='bookmark' title='Remove vmware memory limits with Powershell'>Remove vmware memory limits with Powershell</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.peetersonline.nl/index.php/vmware/create-a-vswitch-port-overview-with-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

