So, I tried a couple of things.
I added the following:
$NetLabel = $vms[$vmi].NetLabel #Read from CSV File the Network Label
and in the build host I tried adding:
-NetworkName (Get-VirtualPortgroup -Name $NetLabel -VMHost $vhost)
I also attempted,
$NetLabel = Get-VirtualPortgroup -Name $vms[$vmi].NetLabel
and then call
-NetworkName $NetLabel.
The error I'm getting is:
New-VM : Parameter set cannot be resolved using the specified named parameters.
At C:\Temp\VMSetup\powercli\PiicVMDeploymet\DeployPiicVms.ps1:44 char:25
+ $taskTab[(New-VM <<<< -VMHost (Get-VMHost $vhost) -Name $vm -Locatio
n $myFolder -Datastore (Get-Datastore $vhoststore) -Template $myTemplate -DiskS
torageFormat Thin -NetworkName (Get-VirtualPortgroup -Name $NetLabel -VMHost $v
host) -OSCustomizationSpec (Get-OSCustomizationSpec $myOsCustomSpec) -RunAsync
-Confirm:$False).Id] = $vm
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingE
xception
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCor
e.Cmdlets.Commands.NewVM
if I execute:
$NetLabel = $vms[$vmi].NetLabel
Get-VirtualPortgroup -Name $NetLabel
all by itself, i get back:
3KBed-Bedsides-02 key-vim.host.PortGroup-3KBe... 139
3KBed-Bedsides-02 key-vim.host.PortGroup-3KBe... 139
3KBed-Bedsides-02 key-vim.host.PortGroup-3KBe... 139
3KBed-Bedsides-02 key-vim.host.PortGroup-3KBe... 139
3KBed-Bedsides-02 key-vim.host.PortGroup-3KBe... 139