hmm, i like the idea of the second option you provided, but seems a little above my skillset. I think for now I will remove the -Runasync.
So now with this script it does change the portgroup from 140(staging network) to whatever the user puts in a csv file. Only having two issues now.
1. is that IP address of the nic 1 & 2 are not being imported from the csv file
2. is that the MemoryGB and NumCpu changes are also not being changed.
Any hints? I Have looked all over the web for the memory and cpu changes but nothing seems to work
Import-Csv deploy.csv -UseCulture | %{ function UpdateVMSettings { 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 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 } $vm=New-VM -Name $_."Server Name" -Template $_.Template -Host $_."Esx Host" -Datastore $_.Datastore -OSCustomizationSpec $_.Customization -Location "Deployed VMs" -Description $_.Description -Confirm:$false while(!(Get-VM -Name $_."Server Name" -ErrorAction SilentlyContinue)){ sleep 120 } Start-VM $_."Server Name" Get-vm -Name $_."Server Name" | Get-NetworkAdapter | Where {$_.NetworkName -eq 140 } |Set-NetworkAdapter -StartConnected:$true -Connected:$true -NetworkName $_.VLAN -Confirm:$false Set-VM -MemoryGB $_.MemoryGB -NumCpu $_.NumCpu }