VMware Cloud Community
Kiala
Contributor
Contributor
Jump to solution

Auto Deploy Multiple VMs Script Error

Hi Guys,

I am trying to create multiple VMs with unique IP address and NetBIOS name for each VMs thrugh a Powershell script. Here is my scenario:

I have 2 VMs on one of my server x.x.x.x


1. Autodeploy-1 – The VM on which I am running the script through vSphere PowerCLI
2. AutoDeployVM – Template I am using for creating other VMs.

#Script

# Virtual Center Details

$server_address = “x.x.x.x”
$username = “xxx”
$password = “xxxxxx”

# Vm Details
$destination_host = “x.x.x.x”
$template_name = “AutodeployVM”
$datastore_name = “dataStore1 (9)”

$customization = "customfile"

# Name the VMs in this array
$array = “VPS-Test1″,”VPS-Test2″
$iparray = “x.x.x.1″, “x.x.x.2″
$a= 0

Connect-VIServer -Server $server_address -Protocol https -User $username -Password $password

foreach ($vm in $array)
{

Get-OSCustomizationSpec $customization | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $IParray[$a] -SubnetMask z.z.0.0 -DefaultGateway y.y.y.y -Dns x.x.x.35,x.x.x.36

$vm=New-VM -Name $vm -Template $template_name -Host $destination_host -Datastore  $datastore_name -OSCustomizationSpec $customization

-Confirm:$false $a = $a + 1

}

I have placed the customization file (customfile) in the same folder where the script is. Below is the content of my customfile:

New-OSCustomizationSpec -Name Spec -OSType Windows -FullName Administrator -AdminPassword ****** -Domain abcd.com -DomainUsername abc -DomainPassword ********

I am getting following errors:

1. Set-OSCustomizationSpec : A parameter cannot be found that matches parameter name 'IpMode'.

2. New-VM        Could not find Template with name 'AutodeployVM'.

3. New-VM        Template parameter: Could not find any of the objects specified by name.

Can you guys help me with this. Am I missing anything. I am very new to this thing. Appreciate your help.

Thanks,

Kiala

0 Kudos
63 Replies
BTuser9
Contributor
Contributor
Jump to solution

I updated the VMware vCenter Server to 4.1 Update 1 version. But it still gives the same error,

"New-VM  : 3/21/2011 9:35:33 AM    New-VM        The operation for the entity  VirtualMachine-vm-4861 failed with the following message: "Customization  of the guest operating system 'winNetDatacenter64Guest' is not  supported in this configuration. Microsoft Vista (TM) and Linux guests  with Logical Volume Manager are supported only for recent ESX host and  VMware Tools versions. Refer to vCenter documentation for supported  configurations."

At C:\scripts\vm.ps1:24 char:17 +       $vm=New-VM   <<<< -Name $vm -Template $template_name -Host  $destination_host -Datastore $datastore_name -OSCustomizationSpec  $customization -Confirm:$false
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid I'm nearly out of ideas now.

One thing, I noticed that winNetDatacenter64Guest is still marked as experimental in the VirtualMachineGuestOsIdentifier enumeration.

Could you try the script with winNetEnterprise64Guest or winNetStandard64Guest ?

Just to make sure that it is not related to the guest OS identifier.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Ok, I will try if I can do that with Standard version.

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Hi LucD,

I created a template with Windows Server 2003 Enterprise version and tried running the script. It was running good until when it failed at 93% giving me following error:

"New-VM : 3/23/2011 11:55:06 AM    New-VM        The operation for the entity VirtualMachine-vm-4882 failed with the following message: "Cannot complete customization." At C:\scripts\vm.ps1:25 char:17


+       $vm=New-VM <<<<  -Name $vm -Template $template_name -Host $destination_host -Datastore  $datastore_name -OSCustomizationSpec $customization -Confirm:$false    + CategoryInfo          : NotSpecified: (:) [New-VM], CustomizationFault    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

"

VMware tools is installed on the template.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Could it be that you have an outdated VMware Tools version in your template ?

See Cannot Complete Customization


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Yes, I refered that post earlier. VMware tools is up to date with latest version.

I have updated my vCenter to 4.1 update 1. So, I also re-entered Administrator (and/or) a Domain Account password into the Customization Specifications file. Still the same errorm, not sure what could be the issue.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is there anything in the vCenter logs around the time you ran the New-VM cmdlet ?

The logs are in C:\ProgramData\VMware\VMware VirtualCenter\Logs and are called vpxd-nnnn.log.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

I am not able to find the logs folder at that location (VirtualCenter folder) after I updated vCenter. Tried searching that vpxd log file, but couldn't find anywhere.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

On what OS do you have vCenter running ? Windows 2003 ?

You can also see the logs from the vSphere client, <Home><System Logs> and select the vCenter server log.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Yes Windows server 2003

Yeh, found the logs from Home><System Logs. Thanks! Smiley Happy But don't exactly understand from the logs where is the issue. Here is the latest logs I found searching keyword "errror":

[2011-03-23 16:25:33.000 05552 info 'App' opID=fab35928] [VpxLRO] -- ERROR task-1356 -- vm-4882 -- vim.VirtualMachine.clone: vim.fault.CustomizationFault:
[2011-03-23 16:27:50.296 01836 error 'App' opID=6D118EC9-00000533] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4882, build: unset) - record does not exist or DB error
[2011-03-23 16:27:50.984 05616 error 'App'] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4882, build: unset) - record does not exist or DB error
[2011-03-23 16:37:46.984 04852 error 'App' opID=992da982] [VpxdInvtId::VpxdInvtIdGetVpxApplicationId] The application vcid size cannot be <= 0 or > 64
[2011-03-23 16:38:04.906 04848 error 'App'] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4887, build: unset) - record does not exist or DB error
[2011-03-23 16:38:06.640 04852 error 'App' opID=992da982] [clone] (ADS) Unexpected exception (vim.fault.CustomizationFault) during clone. Aborting.
[2011-03-23 16:38:06.640 04852 error 'App' opID=992da982] [VmCustomizer] Error occured while creating deploy package. Msg: C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\svr2003 doesn't contain known sysprep files.
[2011-03-23 16:38:08.984 04852 error 'App' opID=992da982] [VpxdVmprovUtil] Wait for vm VPS-Test1 unlink failed
[2011-03-23 16:38:08.984 04852 error 'App' opID=992da982] [VpxdVmprovUtil] Wait for vm VPS-Test1 unlink failed
[2011-03-23 16:38:08.984 04852 verbose 'App' opID=992da982] [VpxdVmprovXaction] Caught std exception (vmodl.fault.SystemError)in processing journal entry (op=7), the entry is ignored
[2011-03-23 16:38:11.125 04852 error 'App' opID=992da982] [VpxdVmprov] Clone failed: vim.fault.CustomizationFault
[2011-03-23 16:38:11.125 04852 error 'App' opID=992da982] [VpxdVmprov] Clone failed: vim.fault.CustomizationFault
[2011-03-23 16:38:11.125 04852 error 'App' opID=992da982] vim.fault.CustomizationFault
[2011-03-23 16:38:11.125 04852 error 'App' opID=992da982] vim.fault.CustomizationFault
[2011-03-23 16:38:11.125 04852 info 'App' opID=992da982] [VpxLRO] -- ERROR task-1363 -- vm-4882 -- vim.VirtualMachine.clone: vim.fault.CustomizationFault:
[2011-03-23 16:38:16.796 05220 error 'App' opID=48bcfbc8] [VpxdInvtId::VpxdInvtIdGetVpxApplicationId] The application vcid size cannot be <= 0 or > 64
[2011-03-23 16:38:32.984 04848 error 'App'] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4888, build: unset) - record does not exist or DB error
[2011-03-23 16:38:34.687 05220 error 'App' opID=48bcfbc8] [clone] (ADS) Unexpected exception (vim.fault.CustomizationFault) during clone. Aborting.
[2011-03-23 16:38:34.687 05220 error 'App' opID=48bcfbc8] [VmCustomizer] Error occured while creating deploy package. Msg: C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep\svr2003 doesn't contain known sysprep files.
[2011-03-23 16:38:38.046 05220 error 'App' opID=48bcfbc8] [VpxdVmprovUtil] Wait for vm VPS-Test2 unlink failed
[2011-03-23 16:38:38.046 05220 error 'App' opID=48bcfbc8] [VpxdVmprovUtil] Wait for vm VPS-Test2 unlink failed
[2011-03-23 16:38:38.046 05220 verbose 'App' opID=48bcfbc8] [VpxdVmprovXaction] Caught std exception (vmodl.fault.SystemError)in processing journal entry (op=7), the entry is ignored
[2011-03-23 16:38:39.187 05220 error 'App' opID=48bcfbc8] [VpxdVmprov] Clone failed: vim.fault.CustomizationFault
[2011-03-23 16:38:39.187 05220 error 'App' opID=48bcfbc8] [VpxdVmprov] Clone failed: vim.fault.CustomizationFault
[2011-03-23 16:38:39.187 05220 error 'App' opID=48bcfbc8] vim.fault.CustomizationFault
[2011-03-23 16:38:39.187 05220 error 'App' opID=48bcfbc8] vim.fault.CustomizationFault
[2011-03-23 16:38:39.187 05220 info 'App' opID=48bcfbc8] [VpxLRO] -- ERROR task-1364 -- vm-4882 -- vim.VirtualMachine.clone: vim.fault.CustomizationFault:
[2011-03-23 16:42:56.328 05552 error 'App' opID=6D118EC9-000005D9] vim.fault.InvalidName
[2011-03-23 16:42:56.328 05552 error 'App' opID=6D118EC9-000005D9] vim.fault.InvalidName
[2011-03-23 16:42:56.328 05552 info 'App' opID=6D118EC9-000005D9] [VpxLRO] -- ERROR task-internal-5129 --  -- vim.option.OptionManager.queryView: vim.fault.InvalidName:
[2011-03-23 16:43:41.078 05552 error 'App' opID=6D118EC9-000005DA] Connection lost while waiting for the next request on stream TCPStreamWin32(socket=TCP(fd=3688) local=127.0.0.1:8085,  peer=127.0.0.1:3306): class Vmacore::SystemException(An established connection was aborted by the software in your host machine. )
[2011-03-23 16:46:24.125 03060 error 'App' opID=6D118EC9-000005EA] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4882, build: unset) - record does not exist or DB error
[2011-03-23 16:46:24.281 04852 error 'App'] [VpxdInvtVm::DelStaticOverehadFromDb] Unable to delete entry (vm: 4882, build: unset) - record does not exist or DB error
[2011-03-23 16:53:42.921 05220 error 'App' opID=f8423a0d] [clone] (ADS) Unexpected exception (vmodl.fault.InvalidArgument) during clone. Aborting.
[2011-03-23 16:53:42.921 05220 error 'App' opID=f8423a0d] [VmCustomizer] Error occured while creating deploy package. Msg: vmodl.fault.InvalidArgument
[2011-03-23 16:53:42.921 05220 error 'App' opID=f8423a0d] [VpxdVmprov] Clone failed: vmodl.fault.InvalidArgument
[2011-03-23 16:53:42.921 05220 error 'App' opID=f8423a0d] vmodl.fault.InvalidArgument
0 Kudos
DSTAVERT
Immortal
Immortal
Jump to solution

I suppose just a silly question. Have you used sysprep to prepare your template?

-- David -- VMware Communities Moderator
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I suspect you didn't install the sysprep files on your vCenter server for the Windows 2003 OS.

Have a look at KB1005593

Even though your template is not prepared for sysprep, the cloning process will still look for sysprep files on the vCenter server.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Thanks Dstavert for your input.

LucD, I installed sysprep files on my vCenter server as per the instructions shown in the link you gave. But it's still giving the same error "Cannot complete customization" at 93%.

One thing to notice is my vCenter folder is at a different location, don't know why. It's at C:\Documents and Settings\All Users\Application Data\VMware\VMware VirtualCenter\sysprep

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

I have Windows Server 2003 SP1 64-bit edition.

And I installed this sysprep file - http://www.microsoft.com/downloads/en/details.aspx?familyid=C2684C95-6864-4091-BC9A-52AEC5491AF7&dis...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You have to install the sysprep files for the OS that will run in the guest.

Your vCenter is running on a W2K3 OS, hence the different folder location.

But you are deploying a guest with W2K8, that means you need to install the sysprep files for W2K8.

In fact you should have sysprep files for all the Win OS you cna have in your guests.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Hi LucD,

Installing correct sysprep files worked and created VMs with customization. Smiley HappySmiley Happy
One question though, after creating VMs when I power them on, they are automatically registering Windows OS with the key and other random windows setup and also restarts couple of times after which it automatically logs in as an administrator and remains as it is. Also than it's asking to activate windows for each VMs separately. Any way to avoid all this things, because I thought it should be all set as the template we have already has a registered and activated version of Windows with all other Windows setup.
When I used to create VMs with VMware Orchestrator before through a template, they were already setup with all these things and ready to use directly.
Also is there a way to create VMs through a VM as a model instead through a template if that solves the issue?
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is the sysprep process that you are seeing.

Even if you activated the VM that became the template afterwards, after the sysprep the Windows OS considers it a new installation, hance the activation.

An alternative would be to just clone an existing VM and then change the essential parts, like hostname, ip adress, adding to a domain,...

I suspect that is what Orchestrator is doing.

This way of working will get you guests with the same sysid, but it seems that this is not considered a real problem anymore.

See The Machine SID Duplication Myth


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Yes, that is what we used to do with Orchestrator. But it was a pain and time consuming to change to change the IPs, computer name, and adding to domain for all the VMs one by one, because we use to create 100 VMs at a stretch. This script solved the issue, but it looks like it too has some of these other limitations.

Is there any other alternative to solve this issue? Thanks again!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you already try with a New-OSCustomization but then with the -ChangeSid:$false parameter ?

That way sysprep will not generate a new SID.

Not sure if this will help with activation though, haven't tried it yet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Kiala
Contributor
Contributor
Jump to solution

Yes, in the New-OSCustomization, I have unchecked the Generate new SID paramter. This is what you meant, tight? Please see the attached screenshot,

SID.gif

0 Kudos