New-VM Value cannot be null. Parameter name: source

Posted by

The following error: “parameter name source cannot be null” is just an exception in the VMWare.VimAutomation.Core module.
With this error its hard to find the actual issue. The version i’ve running:

The actual issue is that there is no  “-NetworkName” or -PortGroup parameter is given. So adding this wil fix the issue.

Just curious so i updated the module to the newest available.
Updated VMware.VimAutomation.Core to version: 11.5
Now the error is more clear.

My test command:

Error: New-VM: PowerCLI could not automatically determine a network to which to attach the VM. Specify a network explicitly using the -NetworkName parameter.

In the newest PowerCli version the error is more clear.
Add a -NetworkName or -PortGroup to fix the error.

Happy Automating 🙂

2 comments

  1. Thought i’d mention something to help anyone out struggling with the changes to New-VM.
    The switch -NetworkName is longer supported for attaching VMs to Distributed Port groups. It still works with -NetworkName at the moment but displays a warning.
    If you switch to the -PortGroup parameter it expects an object of type “VirtualPortGroupBase[]” not a string. It will error if a string is submitted to this parameter.

    The work around is to insure that an additional PowerCLI module is imported VMware.VimAutomation.Vds (11.2.0) – Current version

    With this module the -PortGroup parameter now supports strings as it uses vds module to identify PortGroup required.

    Hope that helps

  2. Nice find! Thanks for reacting :).
    Indeed the VMware.VimAutomation.Vds must be installed. This module comes with the install package when you run the “install-module VMware.PowerCLI” from the PowerShell Gallery.

    Greetings

Leave a Reply

Your email address will not be published. Required fields are marked *