It is possible to use DiskGB parameter in new-vm command that using the -template parameter?
Let me explain: I am creating a VM from a template by a orchestrator. DRS choose an ESX with space for VM, but in the wake of my orchestrator have a disk add command and returns an error of lack of space. DRS not choose the drive with more space, but enough space for vm be created.
I'm wondering now create VM with 'n' disks trying to pass the parameters on a single object to verify that the DRS choose a storage with <template> + <disks> and thought about using something like the following command, only returns an error that is not a parameter is wrong.
New-VM -Name $name -Template $tmp -Datastore $dsc 1 -MemoryGB 1 -NumCPU 1 -DiskGB 10 -NetworkName $network
New-VM : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ New-VM -Name "$name" -Template $tmp -Datastore $dsc -Memorygb 1 -NumCPU 1 -DiskG...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
PowerShell cmdlets can come with different parametersets.
There are parameters that can not be combined because they belong to different parametersets.
The DiskGB and the Template parameters are two such parameters.
You can see these parameter sets clearly when you do a Get-Help.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PowerShell cmdlets can come with different parametersets.
There are parameters that can not be combined because they belong to different parametersets.
The DiskGB and the Template parameters are two such parameters.
You can see these parameter sets clearly when you do a Get-Help.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Tanks LucD,
i created the machine with the following commands
New-OSCustomizationSpec -Name $hostname -OrgName $orgname -Workgroup Workgroup -OSType Windows -FullName Administrator -changeSID –Type NonPersistent Get-OSCustomizationNicMapping -OSCustomizationSpec $hostname | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $ip –SubnetMask $mask –DefaultGateway $gateway -Dns $dns –Position 1
$cpuUsage = @{Expression='CpuUsageMhz'; Descending=$false}
$memoryUsage = @{Expression='MemoryUsageGB'; Descending=$false}
$hostesx = Get-VMHost -location $hostcluster | Where {$_.ConnectionState -eq 'Connected'} | Sort-Object $memoryUsage, $cpuUsage | Select -First 1
$newVm = New-VM -VMHost $hostesx -Datastore $datastorecluster -Location $vmfolder -Name $hostname -template $template –OSCustomizationSpec $hostname
Set-VM -VM $hostname -NumCpu $cpu -MemoryGB $ram -confirm:$false
Get-NetworkAdapter -VM $newVm | Set-NetworkAdapter -NetworkName $portgroup -confirm:$false
Remove-OSCustomizationSpec –OSCustomizationSpec $hostname –Confirm:$false
The machine was created
Name Description Type OSType
---- ----------- ---- ------
dxl0almri005 NonPersistent Linux
Dns :
Wins :
SpecId : 6509ac66-9129-4300-bfe7-6c8ed49ac3cd
Spec : dxl0almri005
SpecType : NonPersistent
NetworkAdapterMac :
Position : 1
IPMode : UseStaticIP
IPAddress : 172.20.121.105
SubnetMask : 255.255.255.0
DefaultGateway : 172.20.121.254
AlternateGateway :
VCApplicationArgument :
Id : /Local=/OSCustomizationNicMapping=OSCustomizationNicMap
pingImpl-dxl0almri005-NonPersistent-1/
Uid : /Local=/OSCustomizationNicMapping=OSCustomizationNicMap
pingImpl-dxl0almri005-NonPersistent-1/
ExtensionData : VMware.Vim.CustomizationAdapterMapping
Client :
Version : 2
PowerState : PoweredOff
Version : v9
Description :
Notes :
Guest : dxl0almri005:
NumCpu : 8
MemoryMB : 32768
MemoryGB : 32
HardDisks : {Hard disk 1}
NetworkAdapters : {Network adapter 1}
UsbDevices : {}
CDDrives : {}
FloppyDrives : {}
Host : php00703.df.intrabb.bb.com.br
HostId : HostSystem-host-1550
VMHostId : HostSystem-host-1550
VMHost : php00703.df.intrabb.bb.com.br
VApp :
FolderId : Folder-group-v982
Folder : vm
ResourcePoolId : ResourcePool-resgroup-987
ResourcePool : Resources
PersistentId : 503b6140-438a-8a6c-5a05-5721ebd265d0
UsedSpaceGB : 40,000010203570127487182617188
ProvisionedSpaceGB : 42,225848375819623470306396485
DatastoreIdList : {Datastore-datastore-4320}
HARestartPriority : ClusterRestartPriority
HAIsolationResponse : AsSpecifiedByCluster
DrsAutomationLevel : AsSpecifiedByCluster
VMSwapfilePolicy : Inherit
VMResourceConfiguration : CpuShares:Normal/1000 MemShares:Normal/20480
GuestId : rhel6_64Guest
Name : dxl0almri005
CustomFields : {[ClusterInvariantVMMId, ], [Contatos, ],
[Data_Criacao, ], [Deprovisionamento, ]...}
ExtensionData : VMware.Vim.VirtualMachine
Id : VirtualMachine-vm-4385
Uid : /VIServer=df\user123@10.8.8.8:443/VirtualMachine=
VirtualMachine-vm-4385/
Client : VMware.VimAutomation.ViCore.Impl.V1.VimClient
But after this process i try create a new disk with the size 540GB and the system/orquestrator return the error:
Insufficient disk space on datastore 'VNXS46LUN13'.
because in datastore only have 300GB.
DRS to create the VM chose the correct space for the creation of this VM/Template (40GB) however not had space to add a disk.
What is the best solution?
Is the ThinProvisioned switch an option ?
Otherwise use the Datastore parameter to point to a datastore where you have the space.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference