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:
1 2 3 4 5 |
PS > get-command new-vm CommandType Name Version Source ----------- ---- ------- ------ Cmdlet New-VM 11.3.0.... VMware.VimAutomation.Core |
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.
1 2 3 4 5 |
PS > get-command new-vm CommandType Name Version Source ----------- ---- ------- ------ Cmdlet New-VM 11.5.0.... VMware.VimAutomation.Core |
My test command:
1 2 3 |
$VMhost = get-vmhost -name "TST01" $DS = Get-datastore -name "DS1" New-VM -VMHost $vmhost -name "TST01" -Datastore $DS -DiskGB 40 -NumCpu 2 -MemoryGB 8 -DiskStorageFormat Thick |
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 🙂
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
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