VMware Cloud Community
satish_halemani
Enthusiast
Enthusiast
Jump to solution

Clone VM configuration

Hi,

I have a requirement to clone a same copy of the VM configuration from one datacenter to another datacenter.

We are basically using HUR to do a storage replication from one DC to another. Once replication completes and has been split, we mount the destination LUN as datastores with 'Re-Signature' option and same datastore name. With this, most of disk mappings are lost especially on VMs with large no of disks and we end up removing those disks and do a manual mapping with the same SCSI controller as that of source VM.

My requirement is i want to automate this and for which i need to capture the below details first from source and then replicate the same to destination VM.

Source VM

VMDK path along with datastore name

VMDK mapping to each scsi controller.

VMDK Disk size

RDM mappings

SCSI controller sharing (if any)

With the above info, i am looking for script to map the VMDK disks with same datastore name and same SCSI controller number at the destination.

If anyone could help me, that would be terrific and will save me a lot of time spent on manual mapping.

Thanks in advance.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The following script will allow you to extract the info you would need for step 1.

Get-VM | Get-HardDisk |

Select @{N='VM';E={$_.Parent.Name}},

    Name,CapacityGB,FileName,@{N='Datastore';E={$_.FileName.Split(']')[0].TrimStart('[')}},

    @{N='SCSIid';E={"{0}:{1}" -f (&{$script:ctrl = Get-ScsiController -HardDisk $_; $script:ctrl.ExtensionData.BusNumber}),$_.ExtensionData.UnitNumber}},

    @{N='SCSI Shared';E={$script:ctrl.BusSharingMode}},

    @{N='RDM';E={if($_.DiskType -match 'Physical'){$_.ScsiCanonicalName}}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

The following script will allow you to extract the info you would need for step 1.

Get-VM | Get-HardDisk |

Select @{N='VM';E={$_.Parent.Name}},

    Name,CapacityGB,FileName,@{N='Datastore';E={$_.FileName.Split(']')[0].TrimStart('[')}},

    @{N='SCSIid';E={"{0}:{1}" -f (&{$script:ctrl = Get-ScsiController -HardDisk $_; $script:ctrl.ExtensionData.BusNumber}),$_.ExtensionData.UnitNumber}},

    @{N='SCSI Shared';E={$script:ctrl.BusSharingMode}},

    @{N='RDM';E={if($_.DiskType -match 'Physical'){$_.ScsiCanonicalName}}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
satish_halemani
Enthusiast
Enthusiast
Jump to solution

Thanks LucD.You are always the best:)

I will try this out.

How about Step#2 wherein I need to map the disks to VM using Powercli with exact same configurations as that info pulled from Step#1?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You will have to use the ReconfigVM method for that.

There's an example in  3.  Re: Automate add Windows Hard Disk


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos