VMware Cloud Community
BartekPL
Contributor
Contributor

Cloning VM and changing settings on a fly...

I am trying to clone a VM and change its parameters using 

NetworkName and OSCustomizationSpec. 

It fails. ERROR: Parameter set cannot be resolved using the specified named parameters.

A full command: 

New-VM -NetworkName: VM DHCP -VM: wamuatapp1 -ResourcePool: cc-vb1-vmware -Name: testapp1 -OSCustomizationSpec: Wam -Location: Discovered virtual machine -Confirm: False -VMHost: cc-vb1-esx01.lwc.local -Datastore: VB1_XtremIO_Datastore5

Any idea what is wrong? Can you use OSCustomizationSpec without calling a Template? 
-NetworkName: VM DHCP -VM: wamuatapp1 -ResourcePool: cc-vb1-vmware -Name: testapp1 -OSCustomizationSpec: Wam -Location: Discovered virtual machine -Confirm: False -VMHost: cc-vb1-esx01.lwc.local -Datastore: VB1_XtremIO_Datastore5
0 Kudos
1 Reply
LucD
Leadership
Leadership

There are several flavours of the New-VM cmdlet, each with it's own parameterset.

You can see these with

Get-Command New-VM -Syntax

This results in

newvm.png

In your example you are cloning an existing VM, with that option you can use an OSCustimzationSpec, but not a NetworkName.

You can pipe the result of the New-VM like this

New-VM -VM wamuatapp1 -ResourcePool cc-vb1-vmware -Name testapp1 -OSCustomizationSpec Wam `

    -Location 'Discovered virtual machine' -Confirm:$False -VMHost cc-vb1-esx01.lwc.local `

    -Datastore VB1_XtremIO_Datastore5 |

Get-NetworkAdapter | Set-NetworkAdapter -NetworkName 'VM DHCP' 

PS: I'm not sure why you have the ':' at the end of each parameter, but that is not needed, except for a Switch parameter.


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

0 Kudos