Howdy,
I feel this is a syntax problem. Need some review and help please.
Writing up a NEW-VM deploy script. The script is prompting the end user for all the custom details that is needed to create the VM. Then modifies a Cust Script in Custom Script Manager to deploy the VM from Template. Everything is going perfectly fine except assigning the Port Group.
According to this link : New-VM - vSphere PowerCLI Cmdlets Reference the Parameter is -NetworkName. In PowerGUI I am getting an error.
Here is the script:
# Connect to vCenter server
Connect-VIServer $vcserver
Get-OSCustomizationSpec TestScript1 | Get-OSCustomizationNicMapping | `
Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $IP `
-SubnetMask $SM -DefaultGateway $GW -Dns 1.2.3.4,1.2.3.5
New-VM -Name $Name -Template TemplateNameHere -VMHost $VMHOST `
-Datastore $Datastore -networkname "VLAN ####" -OSCustomizationSpec TestScript1 `
-Confirm:$false -RunAsync
Setting -NetworkName with hard coded Port Group Name or with a variable gives the same result.
Here is the error I get in PowerGUI:
New-VM : Parameter set cannot be resolved using the specified named parameters.
At C:\Scripts\Massive Deploy Project\testdeploy1.ps1:23 char:5
+ New-VM -Name $Name -Template TemplateNameHere -VMHost $VMHOST `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.C
ommands.NewVM
Thanks
BostonTechGuy