<?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>ben.neise.co.uk</title>
	<atom:link href="http://ben.neise.co.uk/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ben.neise.co.uk</link>
	<description>vSphere &#38; Powershell Scripting</description>
	<lastBuildDate>Thu, 04 Feb 2010 18:50:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Preventing computer password expiry</title>
		<link>http://ben.neise.co.uk/index.php/2010/01/357/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/01/357/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 14:53:45 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=357</guid>
		<description><![CDATA[If you work with non-persistent virtual machines on Windows domains, you will be familiar with your machines being disconnected from the domain every 30 days.When you try to log in, you get a message saying "The trust relationship between this workstation and the primary domain failed.". Her'es how to fix it.]]></description>
			<content:encoded><![CDATA[<p>If you work with non-persistent virtual machines on Windows domains, you will be familiar with your machines being disconnected from the domain every 30 days.When you try to log in, you get a message saying:-</p>
<blockquote><p>&#8220;The trust relationship between this workstation and the primary       domain failed.&#8221;</p></blockquote>
<p>The problem is detailed in this <a href="http://support.microsoft.com/kb/162797">KB Article</a>. What happens is that every 30 days (by default) the client initiates a computer password change on the domain controller. This computer password is used to authenticate the computer as the computer object in AD, and is distinct from the user&#8217;s password. When the non-persistent machine resets, the passwords go out of synchronization and domain authentication fails.</p>
<p>This can be fixed, as per <a href="http://support.microsoft.com/kb/154501/">Microsoft&#8217;s KB article</a>, by disabling the client-initiated computer password changes; this can be done using Local or Group Policy, by script, or by directly editing the registry.</p>
<h1>Using local, or group policy</h1>
<p>Set the key shown below to <strong>Disabled</strong></p>
<p><a href="http://ben.neise.co.uk/wp-content/uploads/2010/01/GPO.png"><img class="alignnone size-full wp-image-358" title="GPO" src="http://ben.neise.co.uk/wp-content/uploads/2010/01/GPO.png" alt="" width="685" height="308" /></a></p>
<h2>Using REGEDIT</h2>
<p>Set the below value to <strong>1</strong></p>
<p><a href="http://ben.neise.co.uk/wp-content/uploads/2010/01/Regedit.png"><img class="alignnone size-full wp-image-359" title="Regedit" src="http://ben.neise.co.uk/wp-content/uploads/2010/01/Regedit.png" alt="" width="652" height="282" /></a></p>
<h1>Using Windows shell script</h1>
<pre> :: Set registry key to disable computer password expiry</pre>
<pre>REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters" /v DisablePasswordChange /t REG_DWORD /d 1 /f</pre>
<p>If you’ve got access to the Domain Controller, you can also set a GPO so that <strong>Domain Controller: Refuse Machine Password Changes</strong> is <strong>Enabled</strong>. This is in <em>Windows Settings </em><em>à Securiy Settings </em><em>à Local Policies </em><em>à Security Options </em>(the same location as the <strong>Domain Member: Disable Machine Account Password Changes</strong>).</p>
<p>Also, if you need to rejoin machines that have already fallen off the domain, you can miss the reboot after removing it from the domain, so:</p>
<ol>
<li>Shut the machine down</li>
<li>Make the drives Persistent</li>
<li>Start the machine and log in</li>
<li>Remove the machine from the domain</li>
<li>Add the machine to the domain</li>
<li>Reboot</li>
<li>Shut-down and make Non-Peristent</li>
</ol>
<p>Skipping the middle reboot saves a couple of minutes (which adds up if you have a lot to do). The above processes can also be scripted through the use of PowerCLI with Invoke-VMCommand and either NETDOM (for XP/Vista) or PowerShell for Windows 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/01/357/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing drive letter assignments after deploying a virtual machine from a template</title>
		<link>http://ben.neise.co.uk/index.php/2010/01/changing-drive-letter-assignments-after-deploying-a-virtual-machine-from-a-template/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/01/changing-drive-letter-assignments-after-deploying-a-virtual-machine-from-a-template/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 13:36:31 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=346</guid>
		<description><![CDATA[Using PowerCLI and DISKPART to change drive letter assignments after specific assignments have been reset by Sysprep during the customisation process.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve had an ongoing problem with &#8220;Sequencing&#8221; machines for <a href="http://en.wikipedia.org/wiki/Microsoft_Application_Virtualization">Microsoft Application Virtualisation</a> (formerly SoftGrid). The virtual machine template is correctly set up with a secondary drive set to Q:\ (the drive letter is integral to the sequencing process). However, when the machines are deployed from the template, the Sysprep part of the customization process <a href="http://social.technet.microsoft.com/forums/en-US/itprovistadeployment/thread/694daccd-a48d-4529-9aaa-555cda297038">results in the drive being &#8220;reset&#8221;</a> to the lowest available &#8211; in this case D:\.</p>
<p>At first, we manually changed these assignments using the Disk Management MMC before setting the drives to non-persistent. Lately, I&#8217;ve been using a DISKPART script, which speeds up the process, but still requires logging into each machine.</p>
<p>I saw Arnim <a href="http://www.van-lieshout.com/2010/01/powercli-get-wmi-info-from-isolated-guests/">van Lieshout&#8217;s post on <strong>Invoke-VMScript</strong> yesterday</a>, and realised that this could be used to run the DISKPART script on multiple machines. In order to get the TXT file used by DISKPART onto the machine, I&#8217;m also using the <strong>Copy-VMGuestFile</strong> command found in <a href="http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/windowstoolkit40U1-200911-releasenotes.html">PowerCLI 4.0 Update 1</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Change drive letter assignment from D to Q</span>
&nbsp;
<span style="color: #008000;"># Gets the specific VMs we're after as an object</span>
<span style="color: #800080;">$objVMs</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>Folder <span style="color: #800000;">&quot;Sequencers&quot;</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>VM <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Sort-Object</span> Name
&nbsp;
<span style="color: #008000;"># Assign the command line required for DISKPART to a variable</span>
<span style="color: #800080;">$strScript</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;IF EXIST D:\ DISKPART /S C:\DiskPart_Change_C_To_Q.txt&quot;</span>
&nbsp;
<span style="color: #008000;"># Loop through the VMs</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objVM</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$objVMs</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008000;"># Let the user know</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> Copying file to <span style="color: #800080;">$objVM</span>
Copy<span style="color: pink;">-</span>VMGuestFile <span style="color: pink;">-</span>Source <span style="color: #800000;">&quot;C:\Tools\DiskPart_Change_C_To_Q.txt&quot;</span> <span style="color: #008080; font-style: italic;">-Destination</span> <span style="color: #800000;">&quot;c:\&quot;</span> <span style="color: pink;">-</span>LocalToGuest <span style="color: pink;">-</span>VM <span style="color: #800080;">$objVM</span> <span style="color: pink;">-</span>HostUser root <span style="color: pink;">-</span>HostPassword password <span style="color: pink;">-</span>GuestUser Administrator <span style="color: pink;">-</span>GuestPassword password
<span style="color: #008080; font-weight: bold;">Write-Host</span> Changing disk partitions on <span style="color: #800080;">$objVM</span>
Invoke<span style="color: pink;">-</span>VMScript <span style="color: #800080;">$strScript</span> <span style="color: pink;">-</span>vm <span style="color: #800080;">$objVM</span> <span style="color: pink;">-</span>HostUser root <span style="color: pink;">-</span>HostPassword password <span style="color: pink;">-</span>GuestUser Administrator <span style="color: pink;">-</span>GuestPassword password <span style="color: pink;">-</span>ScriptType <span style="color: #800000;">&quot;bat&quot;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>The TXT file contained the following:-</p>
<pre>SELECT VOLUME 2
ASSIGN LETTER=Q</pre>
<p>This requires root credentials for the host, and administrator rights on the target machine, but, as Arnim notes, will work in the absence of client network connectivity.</p>
<p>This is a bit of a hack,: leaving the TXT file behind on the C drive; using root credentials rather than an account with the least effective permissions; and having the script contain the credentials in plain-text. However, I&#8217;m enthusiastic about using this solution in a more structured way in future. I&#8217;m already thinking about using it to defragment and <a href="http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx">SDelete</a> our thick-provisioned virtual machines before converting them to Thin provisioned disks.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/01/changing-drive-letter-assignments-after-deploying-a-virtual-machine-from-a-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linked Clones</title>
		<link>http://ben.neise.co.uk/index.php/2010/01/linked-clones/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/01/linked-clones/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 16:18:57 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=330</guid>
		<description><![CDATA[We've started our first “proper” implemenation of Linked Clones in our vSphere 4 environment. While we've done some limited proof-of-concept work, this is the first project to be entirely deployed using Linked Clones. The objective is to reduce the space used by our training machines on our new environment.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve started our first “proper” implemenation of Linked Clones in our vSphere 4 environment. While we&#8217;ve done some limited proof-of-concept work, this is the first project to be entirely deployed using Linked Clones. The objective is to reduce the space used by our training machines on our new environment.</p>
<p>Linked clones allow multiple machines to share a common read-only &#8220;base&#8221; VMDK file, with each machine generating their own delta (REDO). Under normal usage circumstances, the REDO would continue to grow throughout the life of the machine; however as our machines have non-persistent hard drives, they reset to a clean state when powered-down. This makes our environment ideally suited to taking advanatage of the functionality offered by Linked Clones. They can either be created manually (by moving and renaming files on the datastore), or via the APIs, you can get more information on them in this <a href="http://www.vmware.com/support/developer/vc-sdk/linked_vms_note.pdf">White Paper from VMware</a>.</p>
<p>Our training machines are functionally identical to our production machines, and similarly consist of three types &#8211; Capture, Packaging and Verification. These are 11, 8, and 8 GB respectively. The usage patterns are slightly different, as &#8211; unlike &#8220;live&#8221; projects which have a steady stream of work, trainees tend to come in in large batches. This means that the training environment either needs to be continuously large, but mostly idle, or it needs to be regularly redeployed then stripped back.</p>
<p>The benefits achieved via the implementation of Linked Clones in this project resulted in roughly the same ratio of space saving as our proof-of-concepts, but as the number of machines involved was greater, the differences are more pronounced. Also this is the first time we’ve exceeded 8 machines sharing the same VMDK, which is a notable milestone as it is only possible if we limit the number of possible hosts that the machines can run on (<a href="http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&amp;cmd=displayKC&amp;externalId=1003319">there is a VMFS limitation of 8 hosts accessing a VMDK concurrently</a>). As we have DRS enabled, this meant reducing the number of hosts in each cluster to 8 or less.</p>
<p>We deployed twenty-five machines each, of  the three different builds used in a project. All were Windows XP virtual machines</p>
<p>The three machines being used as the parents had their <a href="http://ben.neise.co.uk/index.php/2009/10/using-sdelete-to-maximise-the-amount-of-disk-space-reclaimed-during-conversion-to-thin-provisioned-disks/">slack space on the drives was cleaned</a> using <a href="http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx">SDelete</a>, then the machine was converted to Thin Provisioned using Storage vMotion. It was switched off, and a snapshot was created. This snapshot will form the base for the parent&#8217;s clones.</p>
<p>The machines were deployed using the a script similar to the one at the bottom of this post, and it took just over an hour to deploy and customize all 75 machines. This was considerably faster than the time it would have taken to deploy 75 machines using the normal &#8220;Deploy from template&#8221;  method.</p>
<p>Here are the data:-</p>
<ul>
<li>Estimated space used if deployed traditionally: <strong>675 GB</strong>
<ul>
<li>Capture: 11 GB per machine</li>
<li> Packaging: 8 GB per machine</li>
<li>Verification: 8 GB per machine</li>
</ul>
</li>
</ul>
<ul>
<li>Estimated Space if Deployed as Thin Provisioned, but not Linked Clones: <strong>238.75 GB</strong>
<ul>
<li>Capture: 3.34 GB per machine</li>
<li>Packaging: 3.72 GB per machine</li>
<li>Verification: 2.49 GB per machine</li>
</ul>
</li>
</ul>
<ul>
<li>Space used in current configuration: <strong>19.3 GB</strong>
<ul>
<li>Capture 3.34 GB for parent, plus 0.13 GB per Linked Clone</li>
<li>Packaging 3.72 GB for parent, plus 0.13 GB per Linked Clone</li>
<li>Verification 2.49 GB for parent, plus 0.13 GB per Linked Clone</li>
</ul>
</li>
</ul>
<p>And in graph-format, for extra impact:-</p>
<p><a href="../wp-content/uploads/2010/01/DiskSpaceUsed1.png"><img title="DiskSpaceUsed" src="../wp-content/uploads/2010/01/DiskSpaceUsed1.png" alt="" width="478" height="284" /></a></p>
<p>All size estimates are based on the machines in a powered-down state. When powered on, a swap file (equal to the size of the assigned RAM) is created, and (assuming the machines are non-persistent) REDO files are created on all types of machines.</p>
<p>I’ve been on a few of the machines and they don’t appear to suffer from any noticeable performance degradation, although the true test won’t come until we get considerable concurrent use.</p>
<p>I&#8217;m tentatively declaring this a huge success. Rather than the training environment using 240 GB between training engagaments, it&#8217;s now down to a svelte 20GB, with no reduction in functionality.</p>
<p>Below is a script similar to the one I used to deploy the linked clones. The actual &#8220;meat&#8221;, which deploys the machines was based on Hal Rottenberg&#8217;s <a href="http://poshcode.org/1549">New-LinkedClone.ps1</a> script. As far as possible, I&#8217;ve tried to strip out stuff that&#8217;s specific to our environment (we use the Custom Attributes as an asset management database and to track which machines were deployed from which templates). There&#8217;s probably going to be stuff in there that doesn&#8217;t make much sense, but if you&#8217;ve got a bit of an understanding of PowerShell, you should be able to cut and keep the bits you want.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># Script to deploy linked clones</span>
&nbsp;
<span style="color: #008000;"># List of custom attributes which you're wanting to copy from the template or parent to the newly created machine</span>
<span style="color: #008000;"># (Machines deployed from templates no longer inherit CAs in vSphere 4.0)</span>
<span style="color: #008000;"># These help us track provenance, and provide information to the user</span>
<span style="color: #800080;">$arrStrAttributesToCopy</span> <span style="color: pink;">=</span> <span style="color: pink;">@</span><span style="color: #000000;">&#40;</span>
<span style="color: #800000;">&quot;AD Object Location&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Customisation&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Infrastructure Consultant&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Logon Administrator Name&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Logon Administrator Password&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Logon User Name&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Logon User Password&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Mobilisation Consultant&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Project&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;Role&quot;</span><span style="color: pink;">,</span>
<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008000;"># Name of the Custom Attribute on the parent which contains the name of the customisation to use</span>
<span style="color: #800080;">$CustomFieldName</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Customisation&quot;</span>
&nbsp;
<span style="color: #0000FF;">Function</span> DeployLinkedClone <span style="color: #000000;">&#40;</span><span style="color: #800080;">$strSourceVM</span><span style="color: pink;">,</span> <span style="color: #800080;">$intToBeDeployed</span><span style="color: pink;">,</span> <span style="color: #800080;">$intStartDeployingAtNumber</span><span style="color: pink;">,</span> <span style="color: #800080;">$CustomFieldName</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008000;"># Bases the name of the machine on the second part of the string split by spaces. This assumes that the template follows the standard naming convention of &quot;Tmpl [Name] x.x&quot;</span>
<span style="color: #800080;">$strMachinePrefix</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$strSourceVM</span>.split<span style="color: #000000;">&#40;</span><span style="color: #800000;">' '</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$objVM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VM <span style="color: #800080;">$strSourceVM</span>
<span style="color: #800080;">$viewVM</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objVM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
<span style="color: #800080;">$objCustomization</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>OSCustomizationSpec <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objVM</span>.CustomFields.Item<span style="color: #000000;">&#40;</span><span style="color: #800080;">$CustomFieldName</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># Ensure that the machines does not have a non persistent HD</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objVM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>HardDisk <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Where-Object</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Persistence <span style="color: #FF0000;">-like</span> <span style="color: #800000;">&quot;IndependentNonPersistent&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$objTemplate</span> has a non<span style="color: pink;">-</span>persistent HD<span style="color: pink;">!</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># If the customisation, as specified in the parent's custom attribute does not exist, then quit.</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: pink;">!</span><span style="color: #800080;">$objCustomization</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> Customisation <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objVM</span>.CustomFields.Item<span style="color: #000000;">&#40;</span><span style="color: #800080;">$CustomFieldName</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> not found. Exiting.
<span style="color: #0000FF;">Break</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #000000;">1</span>
<span style="color: #0000FF;">Do</span> <span style="color: #000000;">&#123;</span>
<span style="color: #008000;"># Convert the single digit integer (i.e., &quot;1&quot;) into a double digit (i.e., &quot;01&quot;)</span>
<span style="color: #800080;">$strMachineNumber</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;{0:0#}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$intStartDeployingAtNumber</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># Concatenate the machine name prefix (from the template name) with the double-digit integer, which is incrememted on each loop</span>
<span style="color: #800080;">$strMachineBeingDeployed</span> <span style="color: pink;">=</span> <span style="color: #800080;">$strMachinePrefix</span><span style="color: pink;">+</span><span style="color: #800080;">$strMachineNumber</span>
<span style="color: #008000;"># Check that the machine doesn't already exist</span>
<span style="color: #0000FF;">If</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VM <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$strMachineBeingDeployed</span> <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Machine $strMachineBeingDeployed already exists!&quot;</span>
<span style="color: #0000FF;">Break</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># Let the user know what's going on</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;Deploying new linked-clone &quot;</span> <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$strMachineBeingDeployed</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Blue <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;, from template &quot;</span> <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$strSourceVM</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Blue <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;, using customisation &quot;</span> <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$objCustomization</span> <span style="color: #008080; font-style: italic;">-ForegroundColor</span> Blue <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;, on the same Host as the parent&quot;</span> <span style="color: #008080; font-style: italic;">-NoNewline</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;&quot;</span>
<span style="color: #008000;"># Create the new machine using all these variables</span>
<span style="color: #800080;">$objFolder</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viewVM</span>.parent
<span style="color: #800080;">$specClone</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Vmware.Vim.VirtualMachineCloneSpec
<span style="color: #008000;"># Get the most recent snapshot attached to the machine</span>
<span style="color: #800080;">$specClone</span>.Snapshot <span style="color: pink;">=</span> <span style="color: #800080;">$viewVM</span>.Snapshot.CurrentSnapshot
<span style="color: #008000;"># Create an object to represent the location of the clone</span>
<span style="color: #800080;">$specClone</span>.Location <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> Vmware.Vim.VirtualMachineRelocateSpec
<span style="color: #008000;"># This is the move-type that specifies the new disk backing (which is the bit that makes a linked clone)</span>
<span style="color: #800080;">$specClone</span>.Location.DiskMoveType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;createNewChildDiskBacking&quot;</span>
<span style="color: #008000;"># Run the task with the specified parameters</span>
<span style="color: #800080;">$task</span> <span style="color: pink;">=</span> <span style="color: #800080;">$viewVM</span>.CloneVM_Task<span style="color: #000000;">&#40;</span><span style="color: #800080;">$objFolder</span><span style="color: pink;">,</span> <span style="color: #800080;">$strMachineBeingDeployed</span><span style="color: pink;">,</span> <span style="color: #800080;">$specClone</span><span style="color: #000000;">&#41;</span>
Get<span style="color: pink;">-</span>VIObjectByVIView <span style="color: #800080;">$task</span> <span style="color: pink;">|</span> Wait<span style="color: pink;">-</span>Task <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #008000;"># Get the object for the machine which was just deployed</span>
<span style="color: #800080;">$objTargetVM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>VM <span style="color: #800080;">$strMachineBeingDeployed</span>
<span style="color: #008000;"># Apply the customisation specification to the newly created clone</span>
Set<span style="color: pink;">-</span>VM <span style="color: pink;">-</span>VM <span style="color: #800080;">$objTargetVM</span> <span style="color: pink;">-</span>OSCustomizationSpec <span style="color: #800080;">$objCustomization</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span>
<span style="color: #008000;"># Start the clone</span>
Start<span style="color: pink;">-</span>VM <span style="color: pink;">-</span>VM <span style="color: #800080;">$objTargetVM</span>
<span style="color: #008000;"># Get the view (needed for writing custom attributes)</span>
<span style="color: #800080;">$viewTarget</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objTargetVM</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>View
<span style="color: #008000;"># Loop through each of the custom attributes which are to be copied</span>
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$arrStrAttributeToCopy</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$arrStrAttributesToCopy</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
<span style="color: #008000;"># Read the attribute from the source template</span>
<span style="color: #800080;">$objAttribute</span> <span style="color: pink;">=</span> <span style="color: #800080;">$objVM</span>.CustomFields.Item<span style="color: #000000;">&#40;</span><span style="color: #800080;">$arrStrAttributeToCopy</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># Apply the attribute to the machine object</span>
<span style="color: #800080;">$viewTarget</span>.setCustomValue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$arrStrAttributeToCopy</span><span style="color: pink;">,</span><span style="color: #800080;">$objAttribute</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># Set the &quot;Template&quot; custom attribute to the parent templates</span>
<span style="color: #800080;">$arrStrAttributeToCopy</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Template&quot;</span>
<span style="color: #800080;">$viewTarget</span>.setCustomValue<span style="color: #000000;">&#40;</span><span style="color: #800080;">$arrStrAttributeToCopy</span><span style="color: pink;">,</span><span style="color: #800080;">$strSourceTemplate</span><span style="color: #000000;">&#41;</span>
<span style="color: #008000;"># Increment the number used for naming the machines</span>
<span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: pink;">++</span>
<span style="color: #008000;"># Increment the number used to count the number of machines deployed</span>
<span style="color: #800080;">$i</span> <span style="color: pink;">++</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># Continue to loop while the number of machines deployed is less than the number required</span>
<span style="color: #0000FF;">While</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: #FF0000;">-le</span> <span style="color: #800080;">$intToBeDeployed</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008000;"># Get the current time (for timing how long the script took to run)</span>
<span style="color: #800080;">$dteStart</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
&nbsp;
<span style="color: #008000;"># Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute</span>
<span style="color: #800080;">$strSourceVM</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Tmpl Capture 1.0&quot;</span>
<span style="color: #008000;"># Number to be deployed</span>
<span style="color: #800080;">$intToBeDeployed</span> <span style="color: pink;">=</span> <span style="color: #000000;">25</span>
<span style="color: #008000;"># Number to start deploying from</span>
<span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: pink;">=</span> <span style="color: #000000;">1</span>
DeployLinkedClone <span style="color: #800080;">$strSourceVM</span> <span style="color: #800080;">$intToBeDeployed</span> <span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: #800080;">$CustomFieldName</span>
&nbsp;
<span style="color: #008000;"># Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute</span>
<span style="color: #800080;">$strSourceVM</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Tmpl Packaging 1.0&quot;</span>
<span style="color: #008000;"># Number to be deployed</span>
<span style="color: #800080;">$intToBeDeployed</span> <span style="color: pink;">=</span> <span style="color: #000000;">25</span>
<span style="color: #008000;"># Number to start deploying from</span>
<span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: pink;">=</span> <span style="color: #000000;">1</span>
DeployLinkedClone <span style="color: #800080;">$strSourceVM</span> <span style="color: #800080;">$intToBeDeployed</span> <span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: #800080;">$CustomFieldName</span>
&nbsp;
<span style="color: #008000;"># Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute</span>
<span style="color: #800080;">$strSourceVM</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;Tmpl Verification 1.0&quot;</span>
<span style="color: #008000;"># Number to be deployed</span>
<span style="color: #800080;">$intToBeDeployed</span> <span style="color: pink;">=</span> <span style="color: #000000;">25</span>
<span style="color: #008000;"># Number to start deploying from</span>
<span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: pink;">=</span> <span style="color: #000000;">1</span>
DeployLinkedClone <span style="color: #800080;">$strSourceVM</span> <span style="color: #800080;">$intToBeDeployed</span> <span style="color: #800080;">$intStartDeployingAtNumber</span> <span style="color: #800080;">$CustomFieldName</span>
&nbsp;
<span style="color: #800080;">$dteEnd</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Get-Date</span>
<span style="color: #800080;">$dteDiff</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-TimeSpan</span> <span style="color: #800080;">$dteStart</span> <span style="color: #800080;">$dteEnd</span>
<span style="color: #800080;">$timeTaken</span> <span style="color: pink;">=</span> <span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::round<span style="color: #000000;">&#40;</span><span style="color: #800080;">$dteDiff</span>.totalMinutes<span style="color: pink;">,</span> <span style="color: #000000;">2</span><span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;It took&quot;</span> <span style="color: #800080;">$timeTaken</span> <span style="color: #800000;">&quot;minutes for these machines to deploy&quot;</span>
&nbsp;
<span style="color: #008000;"># End of script</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/01/linked-clones/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy New Year</title>
		<link>http://ben.neise.co.uk/index.php/2010/01/happy-new-year/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/01/happy-new-year/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:00:06 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=326</guid>
		<description><![CDATA[Happy New Year to everyone!

I passed the VCP on vSphere 4 just before Christmas with 463/500. At the time the deadline for taking the exam without having to the attend the What's New was 31st December 2009, but that's now been extended to the 31st January. It was nice to have it out of the way before Christmas though.]]></description>
			<content:encoded><![CDATA[<p>Happy New Year to everyone!</p>
<p>I passed the VCP on vSphere 4 just before Christmas with 463/500. At the time the deadline for taking the exam without having to the attend the <a href="http://mylearn.vmware.com/mgrreg/courses.cfm?ui=www&amp;a=one&amp;id_subject=10069">What&#8217;s New</a> was 31st December 2009, but that&#8217;s <a href="http://mylearn.vmware.com/portals/certification/">now been extended to the 31st January</a>. It was nice to have it out of the way before Christmas though.</p>
<p>The exam seemed no more difficult than the VCP on VI 3; I think they even reused a few of the questions. I found the following useful:-</p>
<ul>
<li><a href="http://www.simonlong.co.uk/blog/vcp-vsphere-4-practice-exam/">Simon Long&#8217;s VCP vSphere 4 Practice Exams</a></li>
<li><a href="http://www.vmware.com/pdf/vsphere4/r40/vsp_40_config_max.pdf">vSphere 4 Configuration Maximums</a></li>
<li><a href="http://virtualisedreality.wordpress.com/vcp-in-vsphere-4-0-study-notes/">Barry Coombs&#8217; VMware vSphere cue-cards</a></li>
</ul>
<p>Those sites also contain numerous links to other resources, so I&#8217;m sure you&#8217;ll find something which will suit your revision style.</p>
<p>Next on my to-do list is the <a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-431&amp;locale=en-us">Microsoft 70-431 Microsoft SQL Server 2005 &#8211; Implementation and Maintenance</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/01/happy-new-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vSphere Bug with DRS, StandBy and Non-Perisistent Hard Drives</title>
		<link>http://ben.neise.co.uk/index.php/2009/12/vsphere-bug-with-drs-standby-and-non-perisistent-hard-drives/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/12/vsphere-bug-with-drs-standby-and-non-perisistent-hard-drives/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 10:36:55 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=321</guid>
		<description><![CDATA[We've been in touch with VMware recently about an issue we were experiencing in vSphere 4, where machines in standby could not be powered on. VMware have now confirmed that this is a bug, and that there will be a fix in R2.

While it's fairly specific to our use-case, I thought I'd share the details in case anyone else runs into this.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been in touch with VMware recently about an issue we were experiencing in vSphere 4, where machines in standby could not be powered on. VMware have now confirmed that this is a bug, and that there will be a fix in R2.</p>
<p>While it&#8217;s fairly specific to our use-case, I thought I&#8217;d share the details in case anyone else runs into this.</p>
<p>First of all, this bug will only affect you if the following conditions are met:</p>
<ul>
<li>You are using VMware vSphere 4.0 (or 4.0 Update 1)</li>
<li> Guest OS power-saving settings cause the virtual machine to enter standby</li>
<li> One or more of the guest&#8217;s hard drives are set to &#8220;independent non-persistent&#8221;</li>
<li> DRS is enabled on the virtual machine&#8217;s cluster</li>
</ul>
<p>The machine enters standby as normal. The issue arises when you try to power the virtual machine back on: if DRS has allocated the machine to another host based on load the machine will not resume, and gives an error similar to the following:-</p>
<blockquote><p>&#8220;Virtual Machine is configured to use a device that prevents the operation: Device &#8216;Hard disk 1&#8242; is disk which is not in persistent mode. Device &#8216;Hard disk 1&#8242; which is not in persistent mode&#8221;.</p></blockquote>
<p>You cannot manually migrate the machine (even back to the original host). You cannot change the power-state on the machine, edit the virtual machine settings, or delete the machine.</p>
<p>If this has happened to you, the only way we&#8217;ve found to get the machine back up-and-running seems to be to remove the machine from inventory, then create a new virtual machine with the same specifications, and add the old machine&#8217;s VMDK.</p>
<p>Fortunately, there are a couple of workarounds. You can either disable power-saving settings in the guest OS or change the guest power management settings from &#8220;Suspend the virtual machine&#8221; to &#8220;Put the guest OS into standby mode and leave the virtual machine powered on&#8221; (you can automate this as described <a href="http://ben.neise.co.uk/index.php/2009/11/changing-standbyaction-using-powershell-script-generated-with-help-from-onyx/">in my previous post</a>).</p>
<ul></ul>
<p>Changing the guest power-management settings means that when the guest enters standby, although vSphere shows the machine as &#8220;powered-on&#8221;, VMware Tools is not running, which can cause problems (i.e., when trying to gracefully shut down a batch of machines).</p>
<p>This was also my first time working with the VMware vSphere support and I was impressed. They quickly replicated the problem and confirmed that it was indeed a bug. As most people nowadays tend to use snapshots rather than non-persistent drives, and few users virtualise desktop operating systems (which are more likely to have power-saving settings on by default) I can understand why this particular set of circumstances went untested.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/12/vsphere-bug-with-drs-standby-and-non-perisistent-hard-drives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing StandByAction Using PowerShell Script Generated with Help from Onyx</title>
		<link>http://ben.neise.co.uk/index.php/2009/11/changing-standbyaction-using-powershell-script-generated-with-help-from-onyx/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/11/changing-standbyaction-using-powershell-script-generated-with-help-from-onyx/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 11:09:33 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=302</guid>
		<description><![CDATA[Using Onyx to generate PowerShell/PowerCLI script to change the StandBy action on a number of machines.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re currently having some issues caused by the <a href="http://communities.vmware.com/thread/244259?tstart=0">convergence of vSphere 4.0, IndependentNonPersistent drives, StandBy and DRS</a> (I&#8217;ll post more on that later).  As a workaround, we needed to modify 228 machines so that they did not go into hibernation. You can do this though the vSphere Client by right clicking the virtual machine, click <strong>Edit Settings</strong>, go to the <strong>Options Tab</strong>, then select <strong>Power Management</strong>, and changing the radio button. We were wanting to change from &#8220;Suspend the virtual machine&#8221; to &#8220;Put the guest OS into standby mode and leave the virtual machine powered on&#8221;.</p>
<p><img class="size-medium wp-image-303 alignleft" title="PowerSettings" src="http://ben.neise.co.uk/wp-content/uploads/2009/11/PowerSettings-300x264.PNG" alt="PowerSettings" width="300" height="264" /></p>
<p>To do this the machines need to be powered down. We had an imminent maintenance window, but it wouldn&#8217;t allow us the time to make this change manually (even if we wanted to), this necessitated some automation. Unfortunately I had no idea how to go about editing this setting using the PowerCLI, even after a little search through the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit">VMware PowerCLI community</a>.</p>
<p>This seemed like the perfect opportunity to try out <a href="http://ben.neise.co.uk/index.php/2009/11/alpha-build-of-project-onyx/">Project Onyx</a>.</p>
<p><a href="http://blogs.vmware.com/vipowershell/2009/11/project-onyx-is-here.html">Carter Shanklin&#8217;s video</a> does a good job of explaining how to Onyx up and running, and it worked exactly as described (even on my Windows 7 machine).</p>
<ol>
<li><a href="http://bit.ly/vmwOnyx15">Download the Onyx files</a> and extract to a folder</li>
<li>Run the Onyx executable</li>
<p><img class="size-medium wp-image-304 alignright" title="OnyxWindow" src="http://ben.neise.co.uk/wp-content/uploads/2009/11/OnyxWindow-300x203.PNG" alt="OnyxWindow" width="300" height="203" /></p>
<li>Click the <strong>Connect</strong> button, and connect to your VirtualCenter server.</li>
<li>Once that&#8217;s launched, start vSphere client, but instead of connecting to your VirtualCenter server, connect to <strong>http://localhost:1545</strong> (Carter actually says <strong>1445</strong> in the video, but you can see on screen that he&#8217;s using <strong>1545</strong>). Use your normal credentials.</li>
<li>Ignore the warning about unencrypted traffic (as Carter explains, the unencrypted traffic is local-only, the network traffic is still encrypted)</li>
<li>Click the <strong>Start </strong>button on Onyx</li>
<li>In vSphere client make whatever changes it is that you&#8217;re wanting to record.</li>
<li>Click the <strong>Pause</strong> button on Onyx, and you&#8217;ll see in the window a script has been created.</li>
<li>Copy this into <a href="http://thevesi.org/index.jspa">your favourite PowerShell editor</a>, and modify until it&#8217;s suitable for your purposes.</li>
</ol>
<p>The original capture from the Onyx Window</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$spec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec
<span style="color: #800080;">$spec</span>.changeVersion <span style="color: pink;">=</span> <span style="color: #800000;">&quot;2009-11-27T09:16:04.570821Z&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineDefaultPowerOpInfo
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultPowerOffType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;soft&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultSuspendType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;hard&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultResetType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;soft&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.standbyAction <span style="color: pink;">=</span> <span style="color: #800000;">&quot;checkpoint&quot;</span>
&nbsp;
<span style="color: #800080;">$_this</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #800000;">'VirtualMachine-vm-1074'</span>
<span style="color: #800080;">$_this</span>.ReconfigVM_Task<span style="color: #000000;">&#40;</span><span style="color: #800080;">$spec</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>A second capture changing the setting back to isolate the exact line that makes the changes</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$spec</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec
<span style="color: #800080;">$spec</span>.changeVersion <span style="color: pink;">=</span> <span style="color: #800000;">&quot;2009-11-27T09:16:33.872017Z&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineDefaultPowerOpInfo
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultPowerOffType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;soft&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultSuspendType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;hard&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.defaultResetType <span style="color: pink;">=</span> <span style="color: #800000;">&quot;soft&quot;</span>
<span style="color: #800080;">$spec</span>.powerOpInfo.standbyAction <span style="color: pink;">=</span> <span style="color: #800000;">&quot;powerOnSuspend&quot;</span>
&nbsp;
<span style="color: #800080;">$_this</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #800000;">'VirtualMachine-vm-1074'</span>
<span style="color: #800080;">$_this</span>.ReconfigVM_Task<span style="color: #000000;">&#40;</span><span style="color: #800080;">$spec</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>And a finished script, which will run it against all machines in a specified blue folder comment/uncomment one of the $specVM.powerOpInfo.standbyAction lines to choose which option you want.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$objVMs</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>Folder <span style="color: #800000;">&quot;Folder Name&quot;</span> <span style="color: pink;">|</span> Get<span style="color: pink;">-</span>VM
<span style="color: #0000FF;">ForEach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$objVM</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$objVMs</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$specVM</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec
	<span style="color: #800080;">$specVM</span>.powerOpInfo <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineDefaultPowerOpInfo
	<span style="color: #800080;">$specVM</span>.powerOpInfo.standbyAction <span style="color: pink;">=</span> <span style="color: #800000;">&quot;checkpoint&quot;</span> 			<span style="color: #008000;"># Put the guest OS into StandBy Mode and leave the Virtual Machine powered On</span>
	<span style="color: #008000;">#$specVM.powerOpInfo.standbyAction = &quot;powerOnSuspend&quot; 		# Suspend the Virtual Machine</span>
	<span style="color: #800080;">$viewVM</span> <span style="color: pink;">=</span> Get<span style="color: pink;">-</span>View <span style="color: #008080; font-style: italic;">-Id</span> <span style="color: #800080;">$objVM</span>.Id
	<span style="color: #800080;">$viewVM</span>.ReconfigVM_Task<span style="color: #000000;">&#40;</span><span style="color: #800080;">$specVM</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I was actually surprised at how easy this was; and I think it&#8217;s going to make me a bit more adventurous with what I attempt to do via the PowerCLI.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/11/changing-standbyaction-using-powershell-script-generated-with-help-from-onyx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vSphere 4.0 Update 1 Released</title>
		<link>http://ben.neise.co.uk/index.php/2009/11/vsphere-4-0-update-1-released/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/11/vsphere-4-0-update-1-released/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 13:22:27 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=298</guid>
		<description><![CDATA[VMware have released update 1 for vSphere 4.0.]]></description>
			<content:encoded><![CDATA[<p>VMware have released update 1 for vSphere 4.0.</p>
<p>The following enhancements have been made to ESX (from the <a href="http://www.vmware.com/support/vsphere4/doc/vsp_esx40_u1_rel_notes.html#whatsnew">release notes</a>):-</p>
<blockquote><p><strong>VMware View 4.0 support</strong> <strong>–</strong> This release adds support for VMware View 4.0, a solution built specifically for delivering desktops as a managed service from the protocol to the platform.</p>
<p><strong>Windows 7 and Windows 2008 R2 support –</strong>This release adds support for 32-bit and 64-bit versions of Windows 7 as well as 64-bit Windows 2008 R2 as guest OS platforms. In addition, the vSphere Client is now supported and can be installed on a Windows 7 platform. For a complete list of supported guest operating systems with this release, see the <a href="http://www.vmware.com/resources/compatibility/search.php" target="_blank"><em>VMware Compatibility Guide</em></a>.</p>
<p><strong>Enhanced Clustering Support for Microsoft Windows –</strong> Microsoft Cluster Server (MSCS) for Windows 2000 and 2003 and Windows Server 2008 Failover Clustering is now supported on an VMware High Availability (HA) and Dynamic Resource Scheduler (DRS) cluster in a limited configuration. HA and DRS functionality can be effectively disabled for individual MSCS virtual machines as opposed to disabling HA and DRS on the entire ESX/ESXi host<strong>. </strong>Refer to the <em><a href="http://www.vmware.com/pdf/vsphere4/r40_u1/vsp_40_u1_mscs.pdf" target="_blank">Setup for Failover Clustering and  Microsoft Cluster Service</a></em> guide for additional configuration guidelines.</p>
<p><strong>Enhanced VMware Paravirtualized SCSI Support</strong><strong> –</strong> Support for boot disk devices attached to a Paravirtualized SCSI ( PVSCSI) adapter has been added for Windows 2003 and 2008 guest operating systems. Floppy disk images are also available containing the driver for use during the Windows installation by selecting F6 to install additional drivers during setup. Floppy images can be found in the <tt>/vmimages/floppies/</tt> folder.</p>
<p><strong>Improved vNetwork Distributed Switch  Performance</strong> <strong>–</strong> Several performance and usability issues have been resolved resulting in the following:</p>
<ul>
<li>Improved performance when making configuration changes to a vNetwork Distributed Switch (vDS) instance when the ESX/ESXi host is under a heavy load</li>
<li>Improved performance when adding or removing an ESX/ESXi host to or from a vDS instance</li>
</ul>
<p><strong>Increase in vCPU per Core Limit</strong> <strong>–</strong> The limit on vCPUs per core has been increased from 20 to 25. This change raises the supported limit only. It does not include any additional performance optimizations. Raising the limit allows users more flexibility to configure systems based on specific workloads and to get the most advantage from increasingly faster processors. The achievable number of vCPUs per core depends on the workload and specifics of the hardware. For more information see the <em><a href="http://www.vmware.com/pdf/Perf_Best_Practices_vSphere4.0.pdf" target="_blank">Performance Best Practices for VMware vSphere 4.0</a></em> guide.</p>
<p><strong>Enablement of Intel Xeon Processor 3400 Series</strong> – Support for the Xeon processor 3400 series has been added. For a complete list of supported third party hardware and devices, see the <a href="http://www.vmware.com/resources/compatibility/search.php" target="_blank">VMware Compatibility Guide</a>.</p></blockquote>
<p>vCenter 4.0 has also been updated, and now has full compatibility with Windows 7 x86 and x64 versions. Saving the <a href="http://xtravirt.com/running-vmware-vsphere-client-windows-7">various hacks that were necessary to get it working</a>.</p>
<p>Also, the PowerCLI has been updated, and can be found <a href="http://blogs.vmware.com/vipowershell/2009/11/powercli-40-u1-is-out.html">here</a>. There are 68 new CMDLETS, which <a href="http://www.virtu-al.net/2009/11/20/powercli-bring-on-the-next-version/">Alan Renouf does a great job of explaining</a>. I&#8217;m especially looking forward to trying out Get\Set-CustomAttribute (no more manipulation of the View object), Move-VMTemplate (no more converting templates to machines), and Get\Set-VMQuestion (for those times when the datastores run out of space for the REDO files necessitated by Non-Persistent disks).</p>
<p>I&#8217;m looking forward to investigating the new PowerCLI functionality, and I&#8217;m also looking forward to not needing to  manually customise the dozen or so Windows 7 guests I&#8217;m deploying next week!</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/11/vsphere-4-0-update-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Alpha build of Project Onyx</title>
		<link>http://ben.neise.co.uk/index.php/2009/11/alpha-build-of-project-onyx/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/11/alpha-build-of-project-onyx/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 10:39:53 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=294</guid>
		<description><![CDATA[VMware have released an Alpha build of Project Onyx. This is a script recorder for vSphere Client, which is designed to allow scripting of things which are awkward or difficult to achieve using the VMware PowerCLI APIs alone]]></description>
			<content:encoded><![CDATA[<p>Carter Shanklin has announced that VMware have released an <a href="http://blogs.vmware.com/vipowershell/2009/11/project-onyx-is-here.html">Alpha build of the long-anticipated Project Onyx</a>. This is a script recorder for vSphere Client, which is designed to allow scripting of things which are awkward or difficult to achieve using the VMware PowerCLI APIs alone.<br />
<P><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/bANfdjuH4wk&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/bANfdjuH4wk&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object><br />
<P>Downloading this at the moment, although I don&#8217;t suspect I&#8217;ll have time to look at it for a while.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/11/alpha-build-of-project-onyx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SDelete to maximise the amount of disk space reclaimed during conversion to thin-provisioned disks</title>
		<link>http://ben.neise.co.uk/index.php/2009/10/using-sdelete-to-maximise-the-amount-of-disk-space-reclaimed-during-conversion-to-thin-provisioned-disks/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/10/using-sdelete-to-maximise-the-amount-of-disk-space-reclaimed-during-conversion-to-thin-provisioned-disks/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:48:15 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=290</guid>
		<description><![CDATA[Experiment to see how much extra space is reclaimed when using SDelete prior to converting a machine to Thin Provisioned disk format on vSphere.]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re currently neck-deep in migration at the moment, but despite the workload, it&#8217;s always worth considering what we can do now, that might save us some time and effort later on.</p>
<p>One of the reasons we were moving to vSphere was the ability to thin-provision (TP) our disks, which we&#8217;re hoping will allow us to increase the amount of machines that we can provision without needing to allocate more storage (currently 18 TB).  I found an article by <a href="http://www.yellow-bricks.com/2009/07/31/storage-vmotion-and-moving-to-a-thin-provisioned-disk/">Duncan Epping over at Yellow Bricks</a> suggesting the use of <a href="http://technet.microsoft.com/en-ca/sysinternals/bb897443.aspx">Sysinternals SDelete</a> utility before the conversion to TP.</p>
<p>Essentially, as deleted files are not zeroed in Windows, and because VMware looks at the raw disk when “deallocating” space during conversion to think provisioned disks; deleted data are not reclaimed.  Running SDelete in the Windows guest before converting the disk to thin provisioned format zeroes the deleted data and should allow the maximum amount of space to be reclaimed.</p>
<p>While I don&#8217;t doubt that this is all correct, I wasn&#8217;t sure how much extra space it would allow us to reclaim. The majority of our guests are relatively small windows clients, almost all of which have non-persistent hard drives; of course &#8211; once they&#8217;ve been made non-persistent, the drive is effectively frozen, and subsequent use won&#8217;t increase the amount of non-zeroed slack space.</p>
<p>What&#8217;s the best way to see whether this is worthwhile? Run an experiment of course!</p>
<p><strong> </strong></p>
<h1>Method</h1>
<p>I took one of our standard Windows XP guests which had been migrated to the new vSphere infrastructure. It had a 10GB hard drive, currently persistent, but which has been &#8211; for the majority of it&#8217;s 9 month existence &#8211; non-persistent. I examined how much disk space it was using, this was the pre-TP “Control”. I then cloned it without customization. One of the clones was converted to TP during a Storage vMotion operation. The other had slack space zeroed using SDelete (this process took around 3 minutes). It was then converted to Thin Provisioned disk format using Storage vMotion in the same way as the first machine.</p>
<h1><strong>Results</strong></h1>
<p>Here&#8217;s what happened<strong><br />
</strong></p>
<h2>Normal (Thick) Disk</h2>
<ul>
<li>Provisioned Storage: 10.50 GB</li>
<li>Not-shared Storage: 10.00 GB</li>
<li>Used Storage: 10.00GB</li>
</ul>
<p><img src="file:///C:/Users/BEN_NE%7E1/AppData/Local/Temp/moz-screenshot.png" alt="" /></p>
<h2>Converted to Thin Provisioned</h2>
<ul>
<li>Provisioned Storage: 10.50 GB</li>
<li>Not-shared Storage: 5.05 GB</li>
<li>Used Storage: 5.05 GB</li>
</ul>
<h2>Converted to Thin Provisioned, <strong>after</strong> running SDelete</h2>
<ul>
<li>Provisioned Storage: 10.50 GB</li>
<li>Not-shared Storage: 4.21 GB</li>
<li>Used Storage: 4.21 GB</li>
</ul>
<h1><strong>Conclusion</strong></h1>
<p>Zeroing slack space on this typical machine saved me 0.84 GB (8.4%). For the minimal effort involved, I think this is worthwhile (I have about 500 more machines almost exactly the same as this).</p>
<p>The percentage of free space reclaimed would likely be higher on persistent machines, or larger machines which see frequent creation and deletion of files.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/10/using-sdelete-to-maximise-the-amount-of-disk-space-reclaimed-during-conversion-to-thin-provisioned-disks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XtraVirt&#8217;s vAlarm</title>
		<link>http://ben.neise.co.uk/index.php/2009/10/xtravirts-valarm/</link>
		<comments>http://ben.neise.co.uk/index.php/2009/10/xtravirts-valarm/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 20:20:58 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=281</guid>
		<description><![CDATA[I've been trying out XtraVirt's vAlarm.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying out <a href="http://xtravirt.com/">XtraVirt</a>&#8217;s vAlarm:-</p>
<blockquote><p>vAlarm is a Windows® based application which monitors alarms generated by VMware® vCenter.</p>
<p>The product is designed to be installed on an administrators PC, and provides automated monitoring of vCenter alarms without needing to be logged into a full VI Client console.</p>
<p>The software automatically communicates with a vCenter server on a user configurable schedule, and notifies any active alarms via a popup information bubble in the notification area of a users desktop.</p>
<p>The option to show details of all active alarms displays an information dialogue which lists individual alarms with detailed descriptions.</p>
<p>The software supports VMware vCenter 2.5 &amp; 4.0.</p></blockquote>
<p>It&#8217;s turned out to be quite handy, as it&#8217;s making me far more conscious of alarms. It might even encourage me to modify the default set of alarms &#8211; I&#8217;m generally not interested in guests going into the red because of CPU or memory due to the nature of the way they&#8217;re used, but I do need to know when hosts and datastores are running close to capacity.</p>
<p>The system tray application pops up a bubble, even when there are no alarms, which isn&#8217;t strictly necessary, and it might be nice to be able to collate notifications from more than one vCenter Server (I&#8217;m currently watching over two); but these are minor quibbles about a free product.</p>
<p>You can download <a href="http://xtravirt.com/xd10130">vAlarm from XtraVirt</a> (free registration required).</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2009/10/xtravirts-valarm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
