Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 214147

Using Powercli I having trouble modifying vm hardware and nic portgroup when deploying from template

$
0
0

Hello,

 

wondering if anyone can help out, i am trying to deploy 1 or more vm from multiple templates, the variables are being imported from a csv file each line is a new VM with specific name, ip, gateway, host, datastore, etc.  The VM provisions no problem but I can't seem to modify the amount of cpu, memory, nic portgroup, IP of nic 1 or 2.  Any help in this would be great, also if there was a way to get the vm to start up after the provisioning process that would be even better.

 

Import-Csv deploy.csv -UseCulture | %{    function UpdateVMSettings {    Write-Host "Changing Portgroup and virtual Hardware..."    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | -MemoryMB $_.MemoryMB -NumCpu $_.NumCpu -Confirm:$false    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '1'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."IP Address" -SubnetMask 255.255.255.0 -DefaultGateway $_."GW" -Confirm:$false    Set-VM $"Server Name" | Get-OSCustomizationSpec $_.Customization | Get-OSCustomizationNicMapping | where { $_.Position -eq '2'} | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_."Maint IP Address" -SubnetMask 255.255.0.0 -DefaultGateway $_."GW" -Confirm:$false    Get-VM |Get-NetworkAdapter |Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -NetworkName $VLAN -Confirm:$false    }      $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" `    -Datastore $_.Datastore -OSCustomizationSpec $_.Customization `    -Confirm:$false -RunAsync
}

 

 

As I am sure you can tell I am not a programmer by any means, i play a little in powercli, look on the forums and try to adapt what I see to my needs, sometimes it works, sometimes it doesn't but I am trying , thanks in advance for any advice anyone might have.


Viewing all articles
Browse latest Browse all 214147

Trending Articles