xml importing values to new-vm

Welcome Forums General PowerShell Q&A xml importing values to new-vm

This topic contains 4 replies, has 2 voices, and was last updated by

3 years, 8 months ago.

  • Author
  • #22555

    Points: 0
    Rank: Member

    PowerCLI C:\Users\kon\Documents\Powerclli> $s.vmwareNEW.newvm

    Name : PAPQMMCNSL01
    Template : template_win2012-r2-std-paravirtual
    VMHost : aus1-esx133.mfidom.local
    ResourcePool : 'Infra-MFRM Exchange'
    HDDGB : 80
    Datastore : aus1-ds-esx_prod-t3-10k-04
    storageformat : EagerZeroedThick
    memoryGB : 4
    Numofcpus : 4
    portgroup : prod-corp-01

    PowerCLI C:\Users\kon\Documents\Powerclli> $s.vmwareNEW.newvm | foreach { new-vm -Name $_.Name -Template $_.Template -VMHost $_.VMHost -ResourcePool $_.Res
    -DiskGB $_.HDDGB -Datastore $_.Datastore -StorageFormat $_.storageformat -MemoryGB $_.memoryGB -NumCpu $_.Numofcpus -Portgroup $_.portgroup}

    New-VM : Parameter set cannot be resolved using the specified named parameters.
    At line:1 char:33
    + $s.vmwareNEW.newvm | foreach { new-vm -Name $_.Name -Template $_.Template -VMHo ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

    Why is this ambiguous?

  • #22556

    Points: 3
    Rank: Member

    What it means is that the cmdlet has multiple ways of running itself, and each way has its own parameter set. You've probably included parameters from two sets, so the command doesn't know which way to turn.

    Simpler example that would generate the same error:

    Get-EventLog -LogName Security -List

    -LogName and -List belong to different parameter sets (look at the command help to see what I mean), and you can't use them both at the same time.

  • #22557

    Points: 3
    Rank: Member

    It's also possible that all the parameters you used belong to multiple parameter sets, AND you did not specify any parameters belonging to only one set, AND the command isn't coded to have a default parameter set – so it doesn't know which parameter set to use. That's what it means by "ambiguous." MOST commands do have a default parameter set (when they have multiples in the first place), but it's something to consider. I don't know this particular command well enough to tell you either way.

  • #22574

    Points: 0
    Rank: Member

    Sir You are a demi-god among men.This is a lesson l should have known and I spent a lot of hours on this trying to figure out why this was not working and it was the param set. Thank you! It says it clearly :


    Specifies the virtual machine template you want to use for the creation of the new virtual machine. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.

    Required? true
    Position? 2
    Default value
    Accept pipeline input? true (ByValue)
    Accept wildcard characters? true


    Stuff like this really makes me what to understand what is going on under the hood. But learning powercli has become a catalyst for me to learn powershell. I hope to build off of this and automate the entire process for my organization.

    I do have another question how does one know by that generic error which switch does not belong? Other than looking it would be nice if the error displayed the param at fault.

  • #22582

    Points: 3
    Rank: Member

    Well, the computer doesn't know what it is you want to do. The error message can't be more specific because none of the parameters are "wrong." You can't use them in that combination, but it has no way of knowing what way would be "right" for you at the time.

The topic ‘xml importing values to new-vm’ is closed to new replies.