I'm looking to clone a VM multiple times changing the network connection and IP address it uses, any help appreciated.
NP, other solution will be running this script :
$vmlist
=
Import-CSV
C:vms.csv
foreach
(
$item
in
$vmlist
) {
# I like to map out my variables
$vmname
=
$item
.vmname
$ipaddr
=
$item
.ipaddress
$subnet
=
$item
.subnet
$gateway
=
$item
.gateway
$pdnswins
=
$item
.pdnswins
$sdnswins
=
$item
.sdnswins
#Get the current interface info
$GuestInterface
= Get
-VMGuestNetworkInterface
-VM
$vmname
-HostCredential
$HostCred
-GuestCredential
$GuestCred
#If the IP in the VM matches, then I don't need to update
If (
$ipaddr
-ne
$(
$GuestInterface
.ip)) {
Set
-VMGuestNetworkInterface
-VMGuestNetworkInterface
$GuestInterface
-HostCredential
$HostCred
-GuestCredential
$GuestCred
-IP
$ipaddr
-Netmask
$subnet
-Gateway
$gateway
-DNS
$pdnswins
,
$sdnswins
-WINS
$pdnswins
,
$sdnswins
}
}
You can clone multiple times, but you should change ip address for each machine.
I'm looking to do somthing like this;
Connect-vCenter
Connect-Cluster
Get-AllAvailableNetworks
For AllTheAvailableNetworks
Clone-VM(Update Network Addapter(AllTheAvailableNetworks), ChangeIP)
END
Hi,
Make a template out of the VM and use guest customization, also check if during cloning it gives option for guest customization if it does then no need to go for template just use guest customization follow below Kb artilce for guest customization:
http://kb.vmware.com/kb/1006842
Regards
Hi,
You can clone and than remove the the network card, recreate network card (if you have a DHCP server) you will get a new ip.
Add-PSSnapin VMware.VimAutomation* -erroraction SilentlyContinue
Connect-VIServer -Server vc
$VM = Get-Vm "networktest"
foreach ($VM in $VMs)
{
$VM | Get-NetworkAdapter | remove-NetworkAdapter -Confirm:$false
New-NetworkAdapter -VM $VM -NetworkName "VM Network" -StartConnected -Confirm:$false
}
If you are cloning and recreating it should already have new IP and DNS name ,
not true... if you clone it cloning everything!
if you deploy from a template it will get a new ip and dns...
sorry I have had wrong conception...
yeah u r right ..
I thought you guys r cloning to template ...
If you rather prefer to clone it to template and deploy VMs , then Vspherw will do the job .
You will need to include a sysprep script in c:\windows\setup ..
NP, other solution will be running this script :
$vmlist
=
Import-CSV
C:vms.csv
foreach
(
$item
in
$vmlist
) {
# I like to map out my variables
$vmname
=
$item
.vmname
$ipaddr
=
$item
.ipaddress
$subnet
=
$item
.subnet
$gateway
=
$item
.gateway
$pdnswins
=
$item
.pdnswins
$sdnswins
=
$item
.sdnswins
#Get the current interface info
$GuestInterface
= Get
-VMGuestNetworkInterface
-VM
$vmname
-HostCredential
$HostCred
-GuestCredential
$GuestCred
#If the IP in the VM matches, then I don't need to update
If (
$ipaddr
-ne
$(
$GuestInterface
.ip)) {
Set
-VMGuestNetworkInterface
-VMGuestNetworkInterface
$GuestInterface
-HostCredential
$HostCred
-GuestCredential
$GuestCred
-IP
$ipaddr
-Netmask
$subnet
-Gateway
$gateway
-DNS
$pdnswins
,
$sdnswins
-WINS
$pdnswins
,
$sdnswins
}
}
will this change the DNS name and IP address . if yes , then you might also consider any traffic hitting the parent VM and also address the issues involving in duplicate machines for few seconds/minutes untill this script execute