<?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 &#187; Uncategorized</title>
	<atom:link href="http://ben.neise.co.uk/index.php/category/uncategorized/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 VMware 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>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>
	</channel>
</rss>
