YevB
Contributor
Contributor

Problem with New-VM "-NumCpu" and "MemoryMB" parameters

Jump to solution

Greetings,

I'm trying to create a new VM, and getting a weird message:

"Parameters set cannot be resolved using the specified named parameters. At:...."

Code:

New-VM -VMHost $VMHost -Name $VM.NAME -Location (Get-Folder "Test") -Datastore (Get-Datastore $VM.VMFS) `

-Template (Get-template $VM.TEMPLATE) -OSCustomizationSpec (Get-OSCustomizationSpec $VM.CUSTSPEC) `

-NumCpu X -Memory Y

Tried: X = 2 , "2", $CPU = 2

Y = 2048 , "2048", $MEMORY= 2048

It's working without the "NumCpu" and "MemoryMB" parameters.

Any ideas?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

The New-VM cmdlet has 4 parametersets.

To see them you can do

Get-Command  New-VM | Select -ExpandProperty ParameterSets | Select Name

In this invocation PS discovered that you are using the Template set (based on the -Template parameter).

And that set doesn't have the -NumCPU parameter.

You can also see that in the online reference for thecmdlet.

New-VM [-VMHost] <VMHost> -Name <String> [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>]
  [-Datastore <Datastore>] [-Template] <Template> [-DiskStorageFormat <VirtualDiskStorageFormat>] 
  [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] 
  [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] 
  [-WhatIf] [-Confirm] [<CommonParameters>] 

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

The New-VM cmdlet has 4 parametersets.

To see them you can do

Get-Command  New-VM | Select -ExpandProperty ParameterSets | Select Name

In this invocation PS discovered that you are using the Template set (based on the -Template parameter).

And that set doesn't have the -NumCPU parameter.

You can also see that in the online reference for thecmdlet.

New-VM [-VMHost] <VMHost> -Name <String> [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>]
  [-Datastore <Datastore>] [-Template] <Template> [-DiskStorageFormat <VirtualDiskStorageFormat>] 
  [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] 
  [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] 
  [-WhatIf] [-Confirm] [<CommonParameters>] 

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
YevB
Contributor
Contributor

Thanks Luc, very helpful.

I just though if you add those parameters, the script will change the CPU num and memory after creation.

0 Kudos
LucD
Leadership
Leadership

You can use the Set-VM cmdlet for that.

Something like

New-VM .... | Set-VM -MemoryMB $x -NumCpu $y

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
YevB
Contributor
Contributor

Thanks, already done that.

0 Kudos
auqf
Contributor
Contributor

the set-vm cmdlet can not support the -diskMB.

LucD 编写:

You can use the Set-VM cmdlet for that.

Something like


New-VM .... | Set-VM -MemoryMB $x -NumCpu $y

____________

Blog: LucD notes

Twitter: lucd22

0 Kudos