Hi Luc,
Sorry for the delay in getting back to you - my home broadband is stuffed so I couldn't log on from home, and I've been in meetings all day today.
Thanks for the great suggestions. I've not determined 1) yet, but I will do that at some point (once I've worked out where it's set).
The log file you suggested has told me why it failed to join the domain:
Joining domain RAND.LOCAL using account vbengsup and password '*****'
A specified logon session does not exist. It may already have been terminated.
Retrying join operation with user = vbengsup@RAND.LOCAL
Logon failure: unknown user name or bad password.
Rpci: Sending request='deployPkg.update.state 4 101 C:\WINDOWS\TEMP\vmware-imc\guestcust.log@Logon failure: unknown user name or bad password.
'
Rpci: Sent request='deployPkg.update.state 4 101 C:\WINDOWS\TEMP\vmware-imc\guestcust.log@Logon failure: unknown user name or bad password.
', reply='', len=0, status=1
Logon failure: unknown user name or bad password.
Customization in progress set to 0 at 2012-Sep-27 13:06:28
Rpci: Sending request='deployPkg.update.state 5 0 C:\WINDOWS\TEMP\vmware-imc\guestcust.log'
Rpci: Sent request='deployPkg.update.state 5 0 C:\WINDOWS\TEMP\vmware-imc\guestcust.log', reply='', len=0, status=1
SysprepDecrypter has unobfuscated the password successfully
A few interesting things here:
1) The number of asterisks in the password is 5 - that's fewer than the number of characters in the specified user password - I'm not sure if that's indicitive of a problem or not (I suspect not because as I said, the customisation works ok ourside of Powershell - it's probably a security thing).
2) The last line looks encouraging
3) I don't understand why it would fail - the customisation stores (I believe) the username and password used to add to the domain so I don't see why it should go wrong here.
The template is running XP (required as it's the platform for older products). The template the machine is cloned from is not in a domain, just a workgroup.
The code I'm running is as follows:
# Get the IP address from the hostname
$IP = [System.Net.Dns]::GetHostAddresses($_.hostname) | select-object IPAddressToString -expandproperty IPAddressToString
$DNS = @()
$DNS = $DNS + "a.b.c.d"
$DNS = $DNS + "w.x.y.z"
$TempCustSpecName = "VB_Cust_" + $_.hostname
Get-OSCustomizationSpec $Customisation | New-OSCustomizationSpec -Type NonPersistent -Name $TempCustSpecName
Get-OSCustomizationSpec $TempCustSpecName | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $IP -SubnetMask 255.255.255.0 -DefaultGateway $DefaultGateway -Dns $DNS
Get-OSCustomizationSpec $TempCustSpecName | Set-OSCustomizationSpec -NamingScheme "Fixed" -NamingPrefix $_.hostname
$j = New-VM -VMhost $_.host -name $_.hostname -Template $TemplateName -Datastore $_.Datastore -OSCustomizationSpec $TempCustSpecName -Location $TargetFolder -RunAsync
If there is anything that you can suggest, I'd love to hear.
Many thanks, as always.
Rgds