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?
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
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
Thanks Luc, very helpful.
I just though if you add those parameters, the script will change the CPU num and memory after creation.
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
Thanks, already done that.
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