<?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, 24 Jun 2010 21:03:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Automatically setting the machine owner as a custom attribute</title>
		<link>http://ben.neise.co.uk/index.php/2010/06/automatically-setting-the-machine-owner-as-a-custom-attribute/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/06/automatically-setting-the-machine-owner-as-a-custom-attribute/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 08:49:58 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=447</guid>
		<description><![CDATA[Script to automatically update a custom attribute with the name of the person who deployed or created the machine.]]></description>
			<content:encoded><![CDATA[<p>As we are constantly creating, moving, renaming and deleting machines, it&#8217;s difficult enough to keep track of machines I have deployed myself; never mind keeping track of what the other team members are doing.</p>
<p>In order to try make it easier to find the owner of a machine, we implemented a custom attribute &#8220;Infrastructure Consultant&#8221;, which the deployer should fill complete. Inevitably, despite the best of intentions, this is occasionally missed, and we end up with machine of unknown provenace.</p>
<p>The following <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> sorts this by finding machines where the custom attribute is empty, then populating it with a best guess, based on the machine&#8217;s event log.</p>
<p>It looks for three types of events:-</p>
<ul>
<li>&#8220;Deploying&#8230;&#8221; covers machines which have been deployed from another template</li>
<li>&#8220;Creating&#8230;&#8221; covers machines which have been imported via <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> Converter</li>
<li>&#8220;Clone of&#8230;&#8221; covers machines cloned from existing machines</li>
</ul>
<p>This seems to cover everything on our environment. If you find something else, then it should be simple enough to add it.</p>
<pre class="brush: powershell;"># Name of the custom attribute which we are wanting to check/update
$strCAInfrastructureConsultant = &quot;Infrastructure Consultant&quot;

# Loop through all the machines
ForEach ($objVM in (Get-VM | Sort-Object Name)){
	Write-Host &quot;Checking &quot; -NoNewline
	Write-Host $objVM -ForegroundColor Blue
	# If the specified custom attribute is empty
	If ($objVM.CustomFields.Item($strCAInfrastructureConsultant) -eq &quot;&quot;){
		# Find the username of the person who created the machine. As this is returned in Domain\Username format, we split it, and take the second portion
		$strInfrastructureConsultant = ((@(($objVM | Get-ViEvent | Where-Object {$_.FullFormattedMessage -match &quot;Deploying*&quot; -or $_.FullFormattedMessage -match &quot;Creating*&quot; -or $_.FullFormattedMessage -match &quot;Clone of*&quot;} | Select-Object Username)))[0].Username).Split(&quot;\&quot;)[1]
		Write-Host &quot;Adding &quot; -NoNewline -ForegroundColor DarkGray
		Write-Host $strInfrastructureConsultant -NoNewline -ForegroundColor White
		Write-Host &quot; as Infrastructure Consultant&quot; -ForegroundColor DarkGray
		# Write that username to the custom attribute
		($objVM | Get-View).setCustomValue($strCAInfrastructureConsultant,$strInfrastructureConsultant)
	}
}</pre>
<p>This doesn&#8217;t take a long time to run, and will hopefully catch all those occasions where we forget to complete the custom attributes on the machine. It could of course be easily modified to check/update any other custom attribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/06/automatically-setting-the-machine-owner-as-a-custom-attribute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Datastore alerts via Twitter</title>
		<link>http://ben.neise.co.uk/index.php/2010/05/datastore-alerts-via-twitter/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/05/datastore-alerts-via-twitter/#comments</comments>
		<pubDate>Thu, 06 May 2010 13:28:41 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[VMware]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=441</guid>
		<description><![CDATA[Using a scheduled task and PowerCLI to send tweets when datastores reach capacity.]]></description>
			<content:encoded><![CDATA[<p>With thin provisioning currently being implemented in our environment, and plans to expand the use of Linked Clones, it&#8217;s become apparent that we&#8217;re going to have to start paying close attention to our datastores.</p>
<p><a href="http://www.vcritical.com/about/">Eric Gray</a>&#8216;s done some great stuff with using <a href="http://www.vcritical.com/2009/10/powershell-prevents-datastore-emergencies/">VMware vCenter alarms with PowerShell to automatically migrate machines</a>. And Carter Shanklin&#8217;s got a <a href="http://blogs.vmware.com/vipowershell/2009/09/how-to-run-powercli-scripts-from-vcenter-alarms.html">great description of a different method</a>, but I was after something which didn&#8217;t involve making any modifications to the <a href="http://ben.neise.co.uk/index.php/tag/vcenter/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vCenter">vCenter</a> server. Not everyone here is familiar with the <a href="http://ben.neise.co.uk/index.php/tag/powershell/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerShell">PowerShell</a> /<a href="http://ben.neise.co.uk/index.php/tag/powercli/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerCLI">PowerCLI</a>, and I didn&#8217;t want to put something in place which would require this knowledge to support (or more likely, require me to be dragged off whatever I&#8217;m doing to take a look!).</p>
<p>I decided to use a scheduled task, running from the reporting server (which already runs the scheduled tasks for the maintenance and reporting scripts). This would periodically check the datastores, and tweet if they exceeded a certain threshold. The team supporting the servers can easily set up their phones for Twitter alerts from the specific user</p>
<p>I spent some time trying to do this using pure <a href="http://ben.neise.co.uk/index.php/tag/powershell/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerShell">PowerShell</a>, using the techniques described by <a href="http://blogs.msdn.com/mikeormond/archive/2009/01/30/updated-twitter-powershell-script.aspx">Mike Ormond</a> and <a href="http://devcentral.f5.com/weblogs/Joe/archive/2008/12/30/introducing-poshtweet---the-powershell-twitter-script-library.aspx">Joe Pruitt</a>, but I could not get it to work via our proxy (rather annoyingly it worked intermittently). As a workaround, I ended up using <a href="http://blueonionsoftware.com/blog.aspx">Blue Onion</a>&#8216;s command-line twitter client <a href="http://blueonionsoftware.com/blog.aspx?p=b46a526d-03ea-40a2-8563-6f66f4838a57">TweetC</a>. This stores the twitter username and password in an INI file, and can be called from within a <a href="http://ben.neise.co.uk/index.php/tag/powershell/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerShell">PowerShell</a> <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>.</p>
<pre class="brush: powershell;"># Load the <a href="http://ben.neise.co.uk/index.php/tag/powercli/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerCLI">PowerCLI</a>
Add-PSSnapin <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.VimAutomation.Core

# Your VI server
$strVIServer = &quot;yourVIServer&quot;

# Percentage free space at which you would like a message
$intThreshold = 10

# Connect to the VI server
Connect-VIServer $strVIServer

# Loop through the datastores
ForEach ($objDatastore in (Get-Datastore | Sort-Object FreeSpaceMB | Select-Object Name, @{Name=&quot;PercentageFreeSpace&quot;;Expression={[math]::round(($_.FreeSpaceMB / $_.CapacityMB * 100), 1)}})){
If ($objDatastore.PercentageFreeSpace -lt $intThreshold){
$objName = $objDatastore.Name
$objFreeSpace = $objDatastore.PercentageFreeSpace
E:\Tools\tweetC\tweetc.exe &quot;$objName has only $objFreeSpace % remaining&quot;
}
}

# Disconnect from the VI server
Disconnect-VIServer -Confirm:$false</pre>
<p>As the screenshot below shows, this works a treat (I adjusted the thresholds for testing).</p>
<p><a href="http://ben.neise.co.uk/wp-content/uploads/2010/05/Capture.png"><img class="alignnone size-medium wp-image-442" title="Datastores Tweeting" src="http://ben.neise.co.uk/wp-content/uploads/2010/05/Capture-300x150.png" alt="Screenshot showing datastore's Twitter posts" width="300" height="150" /></a></p>
<p>The Twitter account is protected (to save it from getting followed by porn-bots). I can now set it up for device alerts, which should hopefully give me a head&#8217;s up on any potential problems. I could also implement other alerts in this method. For example, you could ping a critical machine, and tweet if it&#8217;s not available:</p>
<pre class="brush: powershell;">If ((Get-WmiObject -Class Win32_PingStatus -Filter &quot;Address='CriticalMachineHostname'&quot;).StatusCode -ne 0){
E:\Tools\tweetC\tweetc.exe &quot;Critical machine not reposnding to pings!&quot;
}</pre>
<p>Ideally I&#8217;d like to revisit this, and remove the requirement for TweetC, but in the meantime it seems to be working great.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/05/datastore-alerts-via-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eric Sloof&#8217;s quick guide to using the VMware VIX API with vCenter</title>
		<link>http://ben.neise.co.uk/index.php/2010/04/eric-sloofs-quick-guide-to-using-the-vmware-vix-api-with-vcenter/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/04/eric-sloofs-quick-guide-to-using-the-vmware-vix-api-with-vcenter/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 11:45:32 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[vCenter]]></category>
		<category><![CDATA[vSphere]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=373</guid>
		<description><![CDATA[Eric Sloof from NTPro.NL has posted an excellent short video showing how easy it is to create a VB application to do some simple operations on vSphere virtual machines. Online Training – Automating vSphere with the VIX API from Eric Sloof NTPRO.NL on Vimeo. I can&#8217;t wait to try this out, although I think I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/esloof">Eric Sloof</a> from <a href="http://www.ntpro.nl/blog/">NTPro.NL</a> has posted an excellent short video showing how easy it is to create a VB application to do some simple operations on <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> virtual machines.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=11193427&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=24ff95&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=11193427&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=24ff95&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/11193427">Online Training – Automating vSphere with the VIX API</a> from <a href="http://vimeo.com/esloof">Eric Sloof NTPRO.NL</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>I can&#8217;t wait to try this out, although I think I&#8217;m going to have to do a little Visual Basic study first.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/04/eric-sloofs-quick-guide-to-using-the-vmware-vix-api-with-vcenter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically converting machines to thin provisioned format</title>
		<link>http://ben.neise.co.uk/index.php/2010/03/automatically-converting-machines-to-thin-provisioned-format/</link>
		<comments>http://ben.neise.co.uk/index.php/2010/03/automatically-converting-machines-to-thin-provisioned-format/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 10:19:06 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Powershell Script]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Onyx]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://ben.neise.co.uk/?p=370</guid>
		<description><![CDATA[A script to automatically convert your traditional thick-provisioned machines to thin format.]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t been posting too much here recently I&#8217;m afraid. A lot of the things that I&#8217;m currently working on are pretty specific to the environment here, and are not particularly useful (or indeed, interesting) to anyone else.</p>
<p>One of the things I&#8217;ve been doing might be more generally useful. We needed to convert around 700 of our machines to thin-provisioned format. When migrating to the new environment we&#8217;d stuck to traditional &#8220;thick&#8221; machines, as there was a lot of upheaval, and we didn&#8217;t have the necessary monitoring in place. Now that things have settled, we were looking to take advantage of the thin format to save us some space. We had already run <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/">SDELETE</a> on the (non-persistent) machines during the migration, so we were ready to go.</p>
<p>The conversion process is fairly simple: a new option during a storage vMotion. However, the idea of doing this 700 times did not appeal to me, so I wrote the <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> below to automate the process.</p>
<pre class="brush: powershell;"># Convert Machines To Thin Provisioned
# Ben Neise 16/03/10

# Create an empty array
$arrMachinesToBeConverted = @()

Write-Host &quot;Getting virtual machine objects&quot; -ForegroundColor Blue
Write-Host &quot;&quot;

# Select the broad category of VMs we're looking at, for example all the machines in a specific blue folder
$objVMs = Get-Folder &quot;Projects&quot; | Get-VM | Sort-Object

Write-Host &quot;Generating list of candidates&quot; -ForegroundColor Blue
Write-Host &quot;&quot;

# Loop through all the virtual machines selected
ForEach ($objVM in $objVMs){

	Write-Host &quot;Investigating &quot; -NoNewline
	Write-Host $objVM -ForegroundColor Blue -NoNewline

	# Skip the rest of the loop if the machine is thin provisioned
	If ($objVM | Get-HardDisk | Where-Object {$_.StorageFormat -like &quot;Thin&quot;}){
		Write-Host &quot; - disks are already thin provisioned&quot; -ForegroundColor DarkGray
		continue
	}

	# Skip the rest of the loop is the machine is switched on and non-persistent
	If ($objVM | Where-Object {$_.PowerState -ne &quot;PoweredOff&quot;} | Get-HardDisk | Where-Object {$_.Persistence -notlike &quot;IndependentPersistent&quot;}){
		Write-Host &quot; - switched on and non-persistent&quot; -ForegroundColor DarkGray
		continue
	}

	# Skip the rest of the loop if the machine is powered-on, and has snapshots
	If ($objVM | Where-Object {$_.PowerState -ne &quot;PoweredOff&quot; -and ($objVM | Get-Snapshot)}) {
		Write-Host &quot; - switched on and with snapshots&quot; -ForegroundColor DarkGray
		continue
	}

	# Skips the rest of the loop if the machine has a shared drive and is not set up as fault tolerant (indicating that it's a Linked Clone)
	# Thanks to Keshav Attrey for this method - http://www.vmdev.info/?p=546)
	$viewVM = $objVM | Get-View -Property Name,Summary,Config.Hardware.Device
	$unshared = $viewVM.Summary.Storage.Unshared
	$committed = $viewVM.Summary.Storage.Committed
	$ftInfo = $viewVM.Summary.Config.FtInfo
	If (($unshared -ne $committed) -and (($ftInfo -eq $null) -or ($ftInfo.InstanceUuids.Length -le 1))){
		Write-Host &quot;The machine is a linked clone&quot; -ForegroundColor DarkGray
		continue
	}

	Write-Host &quot;Added to the list of machines to be converted&quot;
	$arrMachinesToBeConverted += $objVM
}

Write-Host &quot;Starting Storage vMotions&quot; -ForegroundColor Blue
Write-Host  $arrMachinesToBeConverted.Count -ForegroundColor Blue -NoNewline
Write-Host &quot; machines to be converted&quot; -ForegroundColor DarkGray
Write-Host &quot;&quot;

ForEach ($objVM in $arrMachinesToBeConverted | Sort-Object){

	# Get the biggest datastore
	$objBiggestDatastore = Get-Datastore | Sort-Object -Property FreeSpaceMB -Descending
	# Select the datastore from the top of the previously generated list (index 0) and remove the preceeding &quot;Datastore-&quot; from it's ID to give us the MOID
	$strTargetDatastore = ($objBiggestDatastore[0].Id).replace('Datastore-','')	

	# Let the user know what's going on
	Write-Host &quot;Migrating machine &quot; -NoNewline
	Write-Host $objVM -ForegroundColor Blue -NoNewline
	Write-Host &quot;, to Thin Provisioned format on datastore &quot; -NoNewline
	Write-Host $objBiggestDatastore[0] -ForegroundColor Blue -NoNewline
	Write-Host &quot;&quot;

	# Get the view of the VM we're moving
	$viewVM = Get-View -VIObject $objVM
	# Remove the preceding &quot;HostSystem-&quot; from the VM's Host's ID, giving us the Host's MOID
	$strTargetHost = ($objVM.host.id).replace('HostSystem-','')
	# Create a task specification for the relocation
	$specRelocate = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineRelocateSpec
	# Add the target datastore to the specification using the MOID
	$specRelocate.datastore = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.ManagedObjectReference
	$specRelocate.datastore.type = &quot;Datastore&quot;
	$specRelocate.datastore.value = $strTargetDatastore
	# Add the host to the specification using the MOID
	$specRelocate.host = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.ManagedObjectReference
	$specRelocate.host.type = &quot;HostSystem&quot;
	$specRelocate.host.value = $strTargetHost
	# This is the specification property that makes the disk Thin Provisioned
	$specRelocate.transform = &quot;sparse&quot;
	# Create the task where the previously specified task is applied to the view of the target VM
	$task = $viewVM.RelocateVM_Task($specRelocate, $priority)
	# Start the task, and wait for it to complete before continuing
	Get-VIObjectByVIView $task | Wait-Task | Out-Null

}</pre>
<p>It works through the collection of virtual machine objects in <strong>$objVMs</strong>, and adds them to an array if they pass certain criteria. They must be:-</p>
<ul>
<li>Not be currently thin provisioned</li>
<li>Not switched on and non-persistent</li>
<li>Not switched on with snapshots</li>
<li>Not a linked clone (thanks to <a href="http://www.vmdev.info/?page_id=2">Keshav Attrey</a> for his <a href="http://www.vmdev.info/?p=546">method of finding linked clones</a>)</li>
</ul>
<p>It then starts a separate loop going through each machine object in the array. I could have integrated the migration task into the first loop, but this approach means you can add a human &#8220;sanity-check&#8221; if you&#8217;ve got certain machines you don&#8217;t want to migrate.</p>
<p>The <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> finds the datastore with the largest amount of free space, and then the actual migration is done using code which I <a href="http://ben.neise.co.uk/index.php/2009/11/changing-standbyaction-using-powershell-script-generated-with-help-from-onyx/">generated using Onyx</a>. The free space on the datastores is re-evaluated before every move. This makes the <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> quite slow, but this isn&#8217;t something you want to rush.</p>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/03/automatically-converting-machines-to-thin-provisioned-format/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>, 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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a></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 <a href="http://ben.neise.co.uk/index.php/tag/powercli/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerCLI">PowerCLI</a> with Invoke-VMCommand and either NETDOM (for XP/Vista) or <a href="http://ben.neise.co.uk/index.php/tag/powershell/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerShell">PowerShell</a> 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[Powershell Script]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>, 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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> 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>
<pre class="brush: powershell;"># Change drive letter assignment from D to Q

# Gets the specific VMs we're after as an object
$objVMs = Get-Folder &quot;Sequencers&quot; | Get-VM | Sort-Object Name

# Assign the command line required for DISKPART to a variable
$strScript = &quot;IF EXIST D:\ DISKPART /S C:\DiskPart_Change_C_To_Q.txt&quot;

# Loop through the VMs
ForEach ($objVM in $objVMs){
# Let the user know
Write-Host Copying file to $objVM
Copy-VMGuestFile -Source &quot;C:\Tools\DiskPart_Change_C_To_Q.txt&quot; -Destination &quot;c:\&quot; -LocalToGuest -VM $objVM -HostUser root -HostPassword password -GuestUser Administrator -GuestPassword password
Write-Host Changing disk partitions on $objVM
Invoke-VMScript $strScript -vm $objVM -HostUser root -HostPassword password -GuestUser Administrator -GuestPassword password -ScriptType &quot;bat&quot;
}&lt;/pre&gt;
The TXT file contained the following:-
&lt;pre&gt;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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> 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[Powershell Script]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[vSphere]]></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 <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> 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> <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>. 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 <a href="http://ben.neise.co.uk/index.php/tag/powershell/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerShell">PowerShell</a>, you should be able to cut and keep the bits you want.</p>
<pre class="brush: powershell;"># <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">Script</a> to deploy linked clones

# List of custom attributes which you're wanting to copy from the template or parent to the newly created machine
# (Machines deployed from templates no longer inherit CAs in <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 4.0)
# These help us track provenance, and provide information to the user
$arrStrAttributesToCopy = @(
&quot;AD Object Location&quot;,
&quot;Customisation&quot;,
&quot;Infrastructure Consultant&quot;,
&quot;Logon Administrator Name&quot;,
&quot;Logon Administrator Password&quot;,
&quot;Logon User Name&quot;,
&quot;Logon User Password&quot;,
&quot;Mobilisation Consultant&quot;,
&quot;Project&quot;,
&quot;Role&quot;,
)

# Name of the Custom Attribute on the parent which contains the name of the customisation to use
$CustomFieldName = &quot;Customisation&quot;

Function DeployLinkedClone ($strSourceVM, $intToBeDeployed, $intStartDeployingAtNumber, $CustomFieldName){
# 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;
$strMachinePrefix = ($strSourceVM.split(' ')[1])
$objVM = Get-VM $strSourceVM
$viewVM = $objVM | Get-View
$objCustomization = Get-OSCustomizationSpec ($objVM.CustomFields.Item($CustomFieldName))
# Ensure that the machines does not have a non persistent HD
If ($objVM | Get-HardDisk | Where-Object {$_.Persistence -like &quot;IndependentNonPersistent&quot;}){
Write-Host $objTemplate has a non-persistent HD!
}
# If the customisation, as specified in the parent's custom attribute does not exist, then quit.
If (!$objCustomization){
Write-Host Customisation ($objVM.CustomFields.Item($CustomFieldName)) not found. Exiting.
Break
}
$i = 1
Do {
# Convert the single digit integer (i.e., &quot;1&quot;) into a double digit (i.e., &quot;01&quot;)
$strMachineNumber = (&quot;{0:0#}&quot; -f $intStartDeployingAtNumber)
# Concatenate the machine name prefix (from the template name) with the double-digit integer, which is incrememted on each loop
$strMachineBeingDeployed = $strMachinePrefix+$strMachineNumber
# Check that the machine doesn't already exist
If ((Get-VM -Name $strMachineBeingDeployed -ErrorAction SilentlyContinue)){
Write-Host &quot;Machine $strMachineBeingDeployed already exists!&quot;
Break
}
# Let the user know what's going on
Write-Host &quot;&quot;
Write-Host &quot;Deploying new linked-clone &quot; -NoNewline
Write-Host $strMachineBeingDeployed -ForegroundColor Blue -NoNewline
Write-Host &quot;, from template &quot; -NoNewline
Write-Host $strSourceVM -ForegroundColor Blue -NoNewline
Write-Host &quot;, using customisation &quot; -NoNewline
Write-Host $objCustomization -ForegroundColor Blue -NoNewline
Write-Host &quot;, on the same Host as the parent&quot; -NoNewline
Write-Host &quot;&quot;
# Create the new machine using all these variables
$objFolder = $viewVM.parent
$specClone = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">Vmware</a>.Vim.VirtualMachineCloneSpec
# Get the most recent snapshot attached to the machine
$specClone.Snapshot = $viewVM.Snapshot.CurrentSnapshot
# Create an object to represent the location of the clone
$specClone.Location = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">Vmware</a>.Vim.VirtualMachineRelocateSpec
# This is the move-type that specifies the new disk backing (which is the bit that makes a linked clone)
$specClone.Location.DiskMoveType = &quot;createNewChildDiskBacking&quot;
# Run the task with the specified parameters
$task = $viewVM.CloneVM_Task($objFolder, $strMachineBeingDeployed, $specClone)
Get-VIObjectByVIView $task | Wait-Task | Out-Null
# Get the object for the machine which was just deployed
$objTargetVM = Get-VM $strMachineBeingDeployed
# Apply the customisation specification to the newly created clone
Set-VM -VM $objTargetVM -OSCustomizationSpec $objCustomization -Confirm:$false
# Start the clone
Start-VM -VM $objTargetVM
# Get the view (needed for writing custom attributes)
$viewTarget = $objTargetVM | Get-View
# Loop through each of the custom attributes which are to be copied
ForEach ($arrStrAttributeToCopy in $arrStrAttributesToCopy){
# Read the attribute from the source template
$objAttribute = $objVM.CustomFields.Item($arrStrAttributeToCopy)
# Apply the attribute to the machine object
$viewTarget.setCustomValue($arrStrAttributeToCopy,$objAttribute)
}
# Set the &quot;Template&quot; custom attribute to the parent templates
$arrStrAttributeToCopy = &quot;Template&quot;
$viewTarget.setCustomValue($arrStrAttributeToCopy,$strSourceTemplate)
# Increment the number used for naming the machines
$intStartDeployingAtNumber ++
# Increment the number used to count the number of machines deployed
$i ++
}
# Continue to loop while the number of machines deployed is less than the number required
While ($i -le $intToBeDeployed)
}

# Get the current time (for timing how long the <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> took to run)
$dteStart = Get-Date

# Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute
$strSourceVM = &quot;Tmpl Capture 1.0&quot;
# Number to be deployed
$intToBeDeployed = 25
# Number to start deploying from
$intStartDeployingAtNumber = 1
DeployLinkedClone $strSourceVM $intToBeDeployed $intStartDeployingAtNumber $CustomFieldName

# Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute
$strSourceVM = &quot;Tmpl Packaging 1.0&quot;
# Number to be deployed
$intToBeDeployed = 25
# Number to start deploying from
$intStartDeployingAtNumber = 1
DeployLinkedClone $strSourceVM $intToBeDeployed $intStartDeployingAtNumber $CustomFieldName

# Name of source VM, should be persistent, should have a snapshot and the customisation specified in the nominated custom attribute
$strSourceVM = &quot;Tmpl Verification 1.0&quot;
# Number to be deployed
$intToBeDeployed = 25
# Number to start deploying from
$intStartDeployingAtNumber = 1
DeployLinkedClone $strSourceVM $intToBeDeployed $intStartDeployingAtNumber $CustomFieldName

$dteEnd = Get-Date
$dteDiff = New-TimeSpan $dteStart $dteEnd
$timeTaken = [math]::round($dteDiff.totalMinutes, 2)
Write-Host &quot;&quot;
Write-Host &quot;It took&quot; $timeTaken &quot;minutes for these machines to deploy&quot;

# End of <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ben.neise.co.uk/index.php/2010/01/linked-clones/feed/</wfw:commentRss>
		<slash:comments>2</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[News]]></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 <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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[Onyx]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></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 <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> recently about an issue we were experiencing in <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 4, where machines in standby could not be powered on. <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> shows the machine as &#8220;powered-on&#8221;, <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a> <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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[Powershell Script]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Onyx]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[vSphere]]></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 <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/powercli/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerCLI">PowerCLI</a>, 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 <a href="http://ben.neise.co.uk/index.php/tag/onyx/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Onyx">Onyx</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/onyx/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Onyx">Onyx</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/onyx/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Onyx">Onyx</a></li>
<li>In <a href="http://ben.neise.co.uk/index.php/tag/vsphere/" class="st_tag internal_tag" rel="tag" title="Posts tagged with vSphere">vSphere</a> client make whatever changes it is that you&#8217;re wanting to record.</li>
<li>Click the <strong>Pause</strong> button on <a href="http://ben.neise.co.uk/index.php/tag/onyx/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Onyx">Onyx</a>, and you&#8217;ll see in the window a <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a> 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 <a href="http://ben.neise.co.uk/index.php/tag/onyx/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Onyx">Onyx</a> Window</p>
<pre class="brush: powershell;">$spec = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineConfigSpec
$spec.changeVersion = &quot;2009-11-27T09:16:04.570821Z&quot;
$spec.powerOpInfo = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineDefaultPowerOpInfo
$spec.powerOpInfo.defaultPowerOffType = &quot;soft&quot;
$spec.powerOpInfo.defaultSuspendType = &quot;hard&quot;
$spec.powerOpInfo.defaultResetType = &quot;soft&quot;
$spec.powerOpInfo.standbyAction = &quot;checkpoint&quot;

$_this = Get-View -Id 'VirtualMachine-vm-1074'
$_this.ReconfigVM_Task($spec)</pre>
<p>A second capture changing the setting back to isolate the exact line that makes the changes</p>
<pre class="brush: powershell;">$spec = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineConfigSpec
$spec.changeVersion = &quot;2009-11-27T09:16:33.872017Z&quot;
$spec.powerOpInfo = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineDefaultPowerOpInfo
$spec.powerOpInfo.defaultPowerOffType = &quot;soft&quot;
$spec.powerOpInfo.defaultSuspendType = &quot;hard&quot;
$spec.powerOpInfo.defaultResetType = &quot;soft&quot;
$spec.powerOpInfo.standbyAction = &quot;powerOnSuspend&quot;

$_this = Get-View -Id 'VirtualMachine-vm-1074'
$_this.ReconfigVM_Task($spec)</pre>
<p>And a finished <a href="http://ben.neise.co.uk/index.php/tag/script/" class="st_tag internal_tag" rel="tag" title="Posts tagged with Script">script</a>, 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>
<pre class="brush: powershell;">$objVMs = Get-Folder &quot;Folder Name&quot; | Get-VM
ForEach ($objVM in $objVMs){
	$specVM = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineConfigSpec
	$specVM.powerOpInfo = New-Object <a href="http://ben.neise.co.uk/index.php/tag/vmware/" class="st_tag internal_tag" rel="tag" title="Posts tagged with VMware">VMware</a>.Vim.VirtualMachineDefaultPowerOpInfo
	$specVM.powerOpInfo.standbyAction = &quot;checkpoint&quot; 			# Put the guest OS into StandBy Mode and leave the Virtual Machine powered On
	#$specVM.powerOpInfo.standbyAction = &quot;powerOnSuspend&quot; 		# Suspend the Virtual Machine
	$viewVM = Get-View -Id $objVM.Id
	$viewVM.ReconfigVM_Task($specVM)
}</pre>
<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 <a href="http://ben.neise.co.uk/index.php/tag/powercli/" class="st_tag internal_tag" rel="tag" title="Posts tagged with PowerCLI">PowerCLI</a>.</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>1</slash:comments>
		</item>
	</channel>
</rss>
