<?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: &#8216;Mass&#8217; sysprep your Windows VMs for Nutanix AHV	</title>
	<atom:link href="https://blog.myvirtualvision.com/2015/10/15/mass-sysprep-your-windows-vms-for-nutanix-ahv/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.myvirtualvision.com/2015/10/15/mass-sysprep-your-windows-vms-for-nutanix-ahv/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mass-sysprep-your-windows-vms-for-nutanix-ahv</link>
	<description>My thoughts on application delivery</description>
	<lastBuildDate>Wed, 27 Jul 2016 13:34:28 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>
		By: Nutanix Acropolis with XenDesktop: 8 simple steps • My Virtual Vision		</title>
		<link>https://blog.myvirtualvision.com/2015/10/15/mass-sysprep-your-windows-vms-for-nutanix-ahv/#comment-30835</link>

		<dc:creator><![CDATA[Nutanix Acropolis with XenDesktop: 8 simple steps • My Virtual Vision]]></dc:creator>
		<pubDate>Thu, 03 Dec 2015 11:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.myvirtualvision.com/?p=3848#comment-30835</guid>

					<description><![CDATA[[&#8230;] ‘Mass’ sysprep your Windows VMs for Nutanix AHV [&#8230;]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] ‘Mass’ sysprep your Windows VMs for Nutanix AHV [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Remko		</title>
		<link>https://blog.myvirtualvision.com/2015/10/15/mass-sysprep-your-windows-vms-for-nutanix-ahv/#comment-29751</link>

		<dc:creator><![CDATA[Remko]]></dc:creator>
		<pubDate>Thu, 15 Oct 2015 11:03:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.myvirtualvision.com/?p=3848#comment-29751</guid>

					<description><![CDATA[Hi Kees,

You already have the XML template in a string so there&#039;s no need to save it to disk and then load it as xml. It&#039;s much easier to simply cast it as xml:

[codesyntax lang=&quot;powershell&quot; lines=&quot;normal&quot;]
$xml = [xml]$template
[/codesyntax]

As for setting the properties in XML, I don&#039;t like hardcoded arrays since it makes the code more difficult to read (and I do read a script before executing it). It&#039;s also more error prone as the order might change in the future.

So instead of this:
$xml.unattend.settings[0].component[1].UserData.FullName = $RegisteredName

I recommend this:

[codesyntax lang=&quot;powershell&quot; lines=&quot;normal&quot;]
$ns = New-Object Xml.XmlNamespaceManager($xml.NameTable)
$ns.AddNamespace(&quot;unattend&quot;, $xml.DocumentElement.NamespaceURI)

$msWinSetup = $xml.SelectSingleNode(&quot;//unattend:settings[@pass=&#039;windowsPE&#039;]/unattend:component[@name=&#039;Microsoft-Windows-Setup&#039;]&quot;, $ns)
$msWinSetup.UserData.FullName = $RegisteredName
$msWinSetup.UserData.Organization = $Organization

$msWinShellSetup = $xml.SelectSingleNode(&quot;//unattend:settings[@pass=&#039;specialize&#039;]/unattend:component[@name=&#039;Microsoft-Windows-Shell-Setup&#039;]&quot;, $ns)
$msWinShellSetup.ComputerName = $ComputerName

$msWinUnattendJoin = $xml.SelectSingleNode(&quot;//unattend:settings[@pass=&#039;specialize&#039;]/unattend:component[@name=&#039;Microsoft-Windows-UnattendedJoin&#039;]&quot;, $ns)
$msWinUnattendJoin.identification.JoinDomain = $DomainName
$msWinUnattendJoin.identification.credentials.UserName = $DomainUser
$msWinUnattendJoin.identification.credentials.Password = ConvertTo-PlainText $DomainPwd
$msWinUnattendJoin.identification.credentials.Domain = $DomainName
[/codesyntax]

]]></description>
			<content:encoded><![CDATA[<p>Hi Kees,</p>
<p>You already have the XML template in a string so there&#8217;s no need to save it to disk and then load it as xml. It&#8217;s much easier to simply cast it as xml:</p>
<p>[codesyntax lang=&#8221;powershell&#8221; lines=&#8221;normal&#8221;]<br />
$xml = [xml]$template<br />
[/codesyntax]</p>
<p>As for setting the properties in XML, I don&#8217;t like hardcoded arrays since it makes the code more difficult to read (and I do read a script before executing it). It&#8217;s also more error prone as the order might change in the future.</p>
<p>So instead of this:<br />
$xml.unattend.settings[0].component[1].UserData.FullName = $RegisteredName</p>
<p>I recommend this:</p>
<p>[codesyntax lang=&#8221;powershell&#8221; lines=&#8221;normal&#8221;]<br />
$ns = New-Object Xml.XmlNamespaceManager($xml.NameTable)<br />
$ns.AddNamespace(&#8220;unattend&#8221;, $xml.DocumentElement.NamespaceURI)</p>
<p>$msWinSetup = $xml.SelectSingleNode(&#8220;//unattend:settings[@pass=&#8217;windowsPE&#8217;]/unattend:component[@name=&#8217;Microsoft-Windows-Setup&#8217;]&#8221;, $ns)<br />
$msWinSetup.UserData.FullName = $RegisteredName<br />
$msWinSetup.UserData.Organization = $Organization</p>
<p>$msWinShellSetup = $xml.SelectSingleNode(&#8220;//unattend:settings[@pass=&#8217;specialize&#8217;]/unattend:component[@name=&#8217;Microsoft-Windows-Shell-Setup&#8217;]&#8221;, $ns)<br />
$msWinShellSetup.ComputerName = $ComputerName</p>
<p>$msWinUnattendJoin = $xml.SelectSingleNode(&#8220;//unattend:settings[@pass=&#8217;specialize&#8217;]/unattend:component[@name=&#8217;Microsoft-Windows-UnattendedJoin&#8217;]&#8221;, $ns)<br />
$msWinUnattendJoin.identification.JoinDomain = $DomainName<br />
$msWinUnattendJoin.identification.credentials.UserName = $DomainUser<br />
$msWinUnattendJoin.identification.credentials.Password = ConvertTo-PlainText $DomainPwd<br />
$msWinUnattendJoin.identification.credentials.Domain = $DomainName<br />
[/codesyntax]</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
