<?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: PowerCLI: Easy vSwitch &amp; PortGroup Setup</title>
	<atom:link href="http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/</link>
	<description>Virtually everything is poshable</description>
	<lastBuildDate>Thu, 09 Sep 2010 15:41:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Mike</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-2486</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Fri, 09 Jul 2010 12:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-2486</guid>
		<description>I used it just the other day against an ESXi 4 host, but not without some issues. I was using a version I am sorta working on that tries to create the vswitches, add portgroups and VMkernel ports and adds vnics to the vswitches. It does this by looking at an existing host and making the new host just like the old one. Still not much of my work - mainly Al&#039;s.

The part ESXi didn&#039;t seem to like was the fact that the VMkernel ports are vmk0, vmk1, etc. instead of looking a bit like ESX portgroups. Still things to look at in &quot;my&quot; version before it is ready to use in Production.</description>
		<content:encoded><![CDATA[<p>I used it just the other day against an ESXi 4 host, but not without some issues. I was using a version I am sorta working on that tries to create the vswitches, add portgroups and VMkernel ports and adds vnics to the vswitches. It does this by looking at an existing host and making the new host just like the old one. Still not much of my work &#8211; mainly Al&#8217;s.</p>
<p>The part ESXi didn&#8217;t seem to like was the fact that the VMkernel ports are vmk0, vmk1, etc. instead of looking a bit like ESX portgroups. Still things to look at in &#8220;my&#8221; version before it is ready to use in Production.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rene Nelson</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-2480</link>
		<dc:creator>Rene Nelson</dc:creator>
		<pubDate>Thu, 08 Jul 2010 15:21:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-2480</guid>
		<description>Does this script work with ESXi?  I get the above Null or Empty error when running against ESX4i, but it works great running against ESX4.</description>
		<content:encoded><![CDATA[<p>Does this script work with ESXi?  I get the above Null or Empty error when running against ESX4i, but it works great running against ESX4.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Virtu-Al</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1795</link>
		<dc:creator>Virtu-Al</dc:creator>
		<pubDate>Tue, 02 Feb 2010 20:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1795</guid>
		<description>No problems, Im just glad its not just me using them ;)</description>
		<content:encoded><![CDATA[<p>No problems, Im just glad its not just me using them <img src='http://www.virtu-al.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1794</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 02 Feb 2010 13:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1794</guid>
		<description>My only real change was to use a variable in place of $_ in the foreach loops. For some reason, it didn&#039;t seem to get the scope of $_ without assigning it to a variable first and then using the variable ($switch or &amp;myPG in my version).

I learned a lot from looking at your script and tweaking it, Al (even if the tweaks turn out to have been unnecessary). Thanks!</description>
		<content:encoded><![CDATA[<p>My only real change was to use a variable in place of $_ in the foreach loops. For some reason, it didn&#8217;t seem to get the scope of $_ without assigning it to a variable first and then using the variable ($switch or &amp;myPG in my version).</p>
<p>I learned a lot from looking at your script and tweaking it, Al (even if the tweaks turn out to have been unnecessary). Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Renouf</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1792</link>
		<dc:creator>Alan Renouf</dc:creator>
		<pubDate>Tue, 02 Feb 2010 11:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1792</guid>
		<description>@Mike, strange, all works fine with my original script on ESX4 here.  I will look through the differences.</description>
		<content:encoded><![CDATA[<p>@Mike, strange, all works fine with my original script on ESX4 here.  I will look through the differences.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1769</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Thu, 28 Jan 2010 20:21:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1769</guid>
		<description>Hmm.. not sure M@rcel. Double-check the way this gets pasted in to PowerCLI perhaps. Watch that line breaks don&#039;t get put in where they shouldn&#039;t be.

Perhaps copy &quot;my&quot; version of the script and paste into notepad or some other text editor and watch for the line breaks. Have you tried to use PowerGUI and its Script Editor at all?

Mike</description>
		<content:encoded><![CDATA[<p>Hmm.. not sure M@rcel. Double-check the way this gets pasted in to PowerCLI perhaps. Watch that line breaks don&#8217;t get put in where they shouldn&#8217;t be.</p>
<p>Perhaps copy &#8220;my&#8221; version of the script and paste into notepad or some other text editor and watch for the line breaks. Have you tried to use PowerGUI and its Script Editor at all?</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: M@rcel</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1768</link>
		<dc:creator>M@rcel</dc:creator>
		<pubDate>Thu, 28 Jan 2010 16:24:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1768</guid>
		<description>Hi Al/Mike,

I&#039;m not very experienced with the PowerCLI, but am very interested in automating the creation of vSwitches and PortGroups. We are using ESX4.
I tried pasting Mike&#039;s script in the PowerCLI, but keep getting this error:

Get-VirtualPortGroup : 28-1-2010 17:02:38    Get-VirtualPortGroup
        Could not find VirtualSwitch with name &#039;vSwitch0&#039;.
At line:8 char:33
+ $BASEHost &#124; Get-VirtualPortGroup &lt;&lt;&lt;&lt;  -VirtualSwitch $switch &#124; Foreach {
    + CategoryInfo          : ObjectNotFound: (vSwitch0:String) [Get-VirtualPortGroup], VimException
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomation.Commands.GetVirtualPortGroup

I even do not get the questions for vCenter server, source and destination server. I&#039;m running the PowerCLI with my vmWare admin account (not root)

Any suggestions?</description>
		<content:encoded><![CDATA[<p>Hi Al/Mike,</p>
<p>I&#8217;m not very experienced with the PowerCLI, but am very interested in automating the creation of vSwitches and PortGroups. We are using ESX4.<br />
I tried pasting Mike&#8217;s script in the PowerCLI, but keep getting this error:</p>
<p>Get-VirtualPortGroup : 28-1-2010 17:02:38    Get-VirtualPortGroup<br />
        Could not find VirtualSwitch with name &#8216;vSwitch0&#8242;.<br />
At line:8 char:33<br />
+ $BASEHost | Get-VirtualPortGroup &lt;&lt;&lt;&lt;  -VirtualSwitch $switch | Foreach {<br />
    + CategoryInfo          : ObjectNotFound: (vSwitch0:String) [Get-VirtualPortGroup], VimException<br />
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomation.Commands.GetVirtualPortGroup</p>
<p>I even do not get the questions for vCenter server, source and destination server. I&#039;m running the PowerCLI with my vmWare admin account (not root)</p>
<p>Any suggestions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-1760</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 26 Jan 2010 14:28:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-1760</guid>
		<description>I had to modify the script a tiny bit (sounds like the above comment #1) to get it to work against ESX 4, but below is my version (with all thanks to Al!). I did get this to work for my vSphere hosts.


$VISRV = Connect-VIServer (Read-Host &quot;Please enter the name of your VI SERVER&quot;)
$BASEHost = Get-VMHost -Name (Read-Host &quot;Please enter the name of your existing server as seen in the VI Client:&quot;)
$NEWHost = Get-VMHost -Name (Read-Host &quot;Please enter the name of the server to configure as seen in the VI Client:&quot;)

$BASEHost &#124;Get-VirtualSwitch &#124;Foreach {
	$switch = $_.Name
   If (($NEWHost &#124;Get-VirtualSwitch -Name $switch -ErrorAction SilentlyContinue)-eq $null){
       Write-Host &quot;Creating Virtual Switch $($_.Name)&quot;
       $NewSwitch = $NEWHost &#124;New-VirtualSwitch -Name $_.Name-NumPorts $_.NumPorts-Mtu $_.Mtu
       #$vSwitch = $_
    }
  $BASEHost &#124; Get-VirtualPortGroup -VirtualSwitch $switch &#124; Foreach {
   		$myPG = $_.name
       If (($NEWHost &#124;Get-VirtualPortGroup -Name $myPG -ErrorAction SilentlyContinue)-eq $null){
           Write-Host &quot;Creating Portgroup $($_.Name)&quot;
           $NewPortGroup = $NEWHost &#124;Get-VirtualSwitch -Name $vSwitch &#124;New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID
        }
    }
}</description>
		<content:encoded><![CDATA[<p>I had to modify the script a tiny bit (sounds like the above comment #1) to get it to work against ESX 4, but below is my version (with all thanks to Al!). I did get this to work for my vSphere hosts.</p>
<p>$VISRV = Connect-VIServer (Read-Host &#8220;Please enter the name of your VI SERVER&#8221;)<br />
$BASEHost = Get-VMHost -Name (Read-Host &#8220;Please enter the name of your existing server as seen in the VI Client:&#8221;)<br />
$NEWHost = Get-VMHost -Name (Read-Host &#8220;Please enter the name of the server to configure as seen in the VI Client:&#8221;)</p>
<p>$BASEHost |Get-VirtualSwitch |Foreach {<br />
	$switch = $_.Name<br />
   If (($NEWHost |Get-VirtualSwitch -Name $switch -ErrorAction SilentlyContinue)-eq $null){<br />
       Write-Host &#8220;Creating Virtual Switch $($_.Name)&#8221;<br />
       $NewSwitch = $NEWHost |New-VirtualSwitch -Name $_.Name-NumPorts $_.NumPorts-Mtu $_.Mtu<br />
       #$vSwitch = $_<br />
    }<br />
  $BASEHost | Get-VirtualPortGroup -VirtualSwitch $switch | Foreach {<br />
   		$myPG = $_.name<br />
       If (($NEWHost |Get-VirtualPortGroup -Name $myPG -ErrorAction SilentlyContinue)-eq $null){<br />
           Write-Host &#8220;Creating Portgroup $($_.Name)&#8221;<br />
           $NewPortGroup = $NEWHost |Get-VirtualSwitch -Name $vSwitch |New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID<br />
        }<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Virtu-Al</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-952</link>
		<dc:creator>Virtu-Al</dc:creator>
		<pubDate>Wed, 09 Sep 2009 21:39:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-952</guid>
		<description>&lt;a href=&quot;#comment-951&quot; rel=&quot;nofollow&quot;&gt;@Kcm  &lt;/a&gt; 
I havent tried it against ESX4 yet but will now !</description>
		<content:encoded><![CDATA[<p><a href="#comment-951" rel="nofollow">@Kcm  </a><br />
I havent tried it against ESX4 yet but will now !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kcm</title>
		<link>http://www.virtu-al.net/2009/06/27/powercli-easy-vswitch-portgroup-setup/comment-page-1/#comment-951</link>
		<dc:creator>Kcm</dc:creator>
		<pubDate>Wed, 09 Sep 2009 20:25:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.virtu-al.net/?p=731#comment-951</guid>
		<description>Has anyone (else) tried this on ESX4?  I keep getting  this error
&quot;The argument cannot be null or empty.
At :line:30 char:60
+            $NewPortGroup = $NEWHost &#124;Get-VirtualSwitch -Name &lt;&lt;&lt;&lt;  $vSwitch &#124;New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID&quot;

Line 30 equates to &quot;$NewPortGroup = $NEWHost.......&quot; on my script.</description>
		<content:encoded><![CDATA[<p>Has anyone (else) tried this on ESX4?  I keep getting  this error<br />
&#8220;The argument cannot be null or empty.<br />
At :line:30 char:60<br />
+            $NewPortGroup = $NEWHost |Get-VirtualSwitch -Name &lt;&lt;&lt;&lt;  $vSwitch |New-VirtualPortGroup -Name $_.Name-VLanId $_.VLanID&quot;</p>
<p>Line 30 equates to &quot;$NewPortGroup = $NEWHost&#8230;&#8230;.&quot; on my script.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
