Hey guys,
I'm trying to deploy a new VM using PowerCLI but it keeps failing.
I first tried this.
New-VM -Name "TestVM02" -Datastore "VMFS5_1" -NumCPU 2 -MemoryMB 8192 -DiskGB 1 -DiskStorageFormat Thin -VMHost "esx07.acme.local"
Which threw an error:
PowerCLI could not automatically determine a network to which to attach the VM. Specify a network explicitly using the -NetworkName parameter.
OK, so I then tried:
New-VM -Name "TestVM02" -Datastore "VMFS5_1" -NumCPU 2 -MemoryMB 8192 -DiskGB 1 -DiskStorageFormat Thin -VMHost "esx07.acme.local" -NetworkName "VM Network"
Which also throws an error.
An error occured but the error message cannot be loaded. The error Id is NetworkBackingInfoBuilder_GetNetworkBackingsByName_NonExistentNetworks
I know the network name exists, and I also tried a couple of the others but get the same error.
Not sure what I'm doing wrong??
You could do something like this
ForEach-Object -Process {
Get-VirtualPortGroup -VMHost $esx |
Select @{N='VMHost';E={$esx.Name}},
@{N='Portgroup';E={$_.Name}},
@{N='Type';E={$_.ExtensionData.Gettype().Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Which PowerCLI version and vSphere version are you using?
Does the following return a portgroup?
If yes, can you try with
New-VM -Name "TestVM02" -Datastore "VMFS5_1" -NumCPU 2 -MemoryMB 8192 -DiskGB 1 -DiskStorageFormat Thin -VMHost "esx07.acme.local" -Portgroup $pg
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LucD,
Thanks for the reply.
I discovered that the host "esx07" is not associated with that network "VM Network".
Probably should of checked that first :smileyblush:
The command works with the associated network.
Appreciate the response.
LucD, is there a way to list which networks each host is associated with?
You could do something like this
ForEach-Object -Process {
Get-VirtualPortGroup -VMHost $esx |
Select @{N='VMHost';E={$esx.Name}},
@{N='Portgroup';E={$_.Name}},
@{N='Type';E={$_.ExtensionData.Gettype().Name}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perfect, love your work!