Hello. First time post, so please be kind. Running into hella errors trying various methods to run this script:
$cloneparams = "c:\scripts\clone-parameters.csv"
import-csv $cloneparams -useculture | %{
get-oscustomizationspec $_."customization" | get-oscustomizationnicmapping |`
set-oscustomizationnicmapping -ipmode UseStaticIp -ipaddress $_.ip -subnetmask $_.subnetmask -defaultgateway $_.gateway
new-vm -vmhost $_."vmhost" -name $_."vm_name" -location $_."folder" -template $_."template_name" -resourcepool $_."resource_pool" -datastore $_."datastore_name" -numcpu $_."numcpu" -memorymb $_."memoryMB" -oscustomizationspec $_.customization -confirm:$false -runasync
}
The error looks like this:
New-VM : Parameter set cannot be resolved using the specified named parameters.
At C:\scripts\clonescript.ps1:14 char:7
+ new-vm <<<< -vmhost $_."vmhost" -name $_."nameyname" -location $_."folder" -template $_."template_name" -resourcepool $_."resource_pool" -datastore $_."datastore_name" -numcpu $_."numcpu" -memorymb $_."memoryMB" -oscustomizationspec $_.customization -confirm:$false -runasync
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
The .csv has these column headers (with appropriate values under each for a bunch of new VMs to be created):
vm_name | template_name | datastore_name | customization | vlan | ip | gateway | subnetmask | dns | folder | resource_pool | numcpu | memoryMB | vmhost |
The oscustomizationspec bit seems to be working, but the New-VM commandlet is obviously not happy.
I have seen that others have posted similar code that seems to be working for them. Any thoughts highly appreciated.
Thanks!