VMware Cloud Community
JSamyn
Contributor
Contributor
Jump to solution

Clone VM with predefined customization spec

I've set up a little script that will clone a machine based upon a 'base' clone and then will apply a customization specification, however I'm running into a few issues. The customization spec has the IPMode set to 'PromptUser' for manual cloning, but according to powershell:

Set-VM : 8/31/2010 3:02:41 PM Set-VM 18CA82B4-F642-4D94-BF20-FBEA4CB58B5E

Invalid customization spec - 'Test' . Currently customizations specs with associated nic mapping objects that have IPMode set to 'PromptUser' are not supported.

I've tried setting it to a static IP, but this will need to be changed for each VM as follows:

0000-1 10.x.x.1

0000-n 10.x.x.n

Using the command Get-OSCustomizationSpec Test | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpAddress 10.0.1.12 for VM 0000-12 won't actually change the IP address:

SpecId Position IPMode IPAddress DefaultGateway

Test-10.90.1.41 1 UseStaticIP 10.0.1.30 10.0.1.254

When I set it to DHCP, I can modify it. So it does work in a way, I was just wondering if I can leave our spec files as they are (all set to PromptUser for the IP alone).

Secondly, I'm using the command Get-OSCustomizationSpec Test | Get-OSCustomizationNicMapping | Remove-OSCustomizationNicMapping -Confirm:$false to remove the temporary changes and it prompts me for:

cmdlet Remove-OSCustomizationNicMapping at command pipeline position 3

Supply values for the following parameters:

OSCustomizationNicMapping[0]:

What exactly does this entail? Thank you in advance for any clarification on the matter. FYI, I'm running PowerCLI 4.0 U1

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ok, I see.

It looks as if the Remove-OSCustomizationNicMapping doesn't accept pipeline objects.

Does this work ?

Remove-OSCustomizationNicMapping -OSCustomizationNicMapping (Get-OSCustomizationSpec Test | Get-OSCustomizationNicMapping) -Confirm:$false

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

If possible, I would advise you to first upgrade to PowerCLI 4.1.

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
JSamyn
Contributor
Contributor
Jump to solution

I'm also using PowerGUI, and that one won't work yet with 4.1 if I'm not mistaken? However if 4.1 has already addressed the above issue, then I'll just have to wait a bit until PowerGUI or ecoshell will allow the use of it.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, I see.

It looks as if the Remove-OSCustomizationNicMapping doesn't accept pipeline objects.

Does this work ?

Remove-OSCustomizationNicMapping -OSCustomizationNicMapping (Get-OSCustomizationSpec Test | Get-OSCustomizationNicMapping) -Confirm:$false

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
nnedev
VMware Employee
VMware Employee
Jump to solution

Hi JSamyn,

Set-OSCustomizationNicMapping

You must specify IP mode and IP information if you want to change the IP of the nic mapping object. I tested it and this works fine with 4.0U1:

Get-OSCustomizationSpec test | Get-OSCustomizationNicMapping

| Set-OSCustomizationNicMapping -IpMode usestaticip -dns 10.10.10.10 -DefautGateway 10.10.10.10 -IpAddress 10.10.10.10 -subnetmask 10.10.10.10

The cmdlet in 4.0U1 release has some issues reporting the right errors. In 4.1 most of these issues are fixed and you will be able to set desired parameters.

Remove-OSCustomizationNicMapping

You should specify the OSCustomizationNicMapping parameter. This cmdlet doesn't have pipeline support due to some API limitation. The nic mapping objects don't have IDs in the API and removing multiple objects from the pipeline may cause a lot of troubles.

Regards,

Nedko Nedev

PowerCLI Development Team

Regards, Nedko Nedev PowerCLI Development Team
JSamyn
Contributor
Contributor
Jump to solution

Thank you both very much for the help! It's much appreciated. The non-piped version did work so I'll be using that one till I can switch over to 4.1.

Nedko, will 4.1 allow me to use the spec file with the IP info being set to PromptUser or will I have to make new spec files with IP info set to DHCP and then specify the correct IP, gateway, dns, etc through the command line when I use it? I was hoping I could leave it to PromptUser and then just specify the IP address as the other objects (gateway, dns) are already set in the spec file.

Reply
0 Kudos
nnedev
VMware Employee
VMware Employee
Jump to solution

JSamyn,

4.1 doesn't support "PromptUser" value. Actually I believe this value is not compatible with automation which is the general purpose of the PowerCLI product.

So you should create a NonPersistent customization spec. It is a client side object and updating it is much more faster:

$nonPersistentSpec = New-OSCustomizationSpec -Type NonPersistent ...

or you can clone an existing spec if you want:

$nonPersistentSpec = New-OSCustomizationSpec -Spec myspec -Type NonPersistent

then you can modify it and apply it to VMs.

Regards,

Nedko Nedev

PowerCLI Development Team

Regards, Nedko Nedev PowerCLI Development Team
JSamyn
Contributor
Contributor
Jump to solution

Thank you, Nedko!

Reply
0 Kudos