Hi Team,
I'm newbie to using PowerCLi, here is my script to create multiple VMs using powercli, and i don't know how to set ip and hard disk for VMs can anyone help me? All gusetOS VMs is ubuntu.
Adding a hard disk can be done with the New-Harddisk cmdlet.
You can also create one or more hard disks on the New-VM cmdlet with the DiskGB parameter.
Setting the IP address is something that needs to be done inside the Guest OS.
You can use an OSCustomizationSpec (see New-OSCustomizationSpec) and refer to it on the New-VM cmdlet with the OSCustomizationSpec parameter.
See for example Solved: Re: Deploy a vm with CLI and OSCustomizationNicMap... - VMware Technology Network VMTN
Another option is to launch a script inside the Guest OS via Invoke-VMScript.
See for example BYE DEBIAN/UBUNTU GUEST CUSTOMIZATION, HELLO POWERCLI AND BASH
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I use DiskGB parameter with template then this error appears:
New-VM : Parameter set cannot be resolved using the specified named parameters.
At E:\powercli\Create VM.ps1:14 char:1
+ New-VM -Name $VMName -DiskGB 40 -Template $Template -ResourcePool $vm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
Here is my script I use to create new vm with template:
That is because Template and DiskGB belong to 2 different parametersets of the New-VM cmdlet.
You can't use both parameters together.
If you need to use Template, you will have to add any additional harddisks after the New-VM with New-Harddisk.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference