When you enable replication on a virtual machine, the Replica virtual machine files are created under the location specified by you in the Replica server configuration on the Replica side. Under the specified location, the files are created under a folder structure that looks like:
The folders are named using GUIDs.
Why are GUIDs used to name the folders?
A fair question to ask. The same Replica server could be receiving replication from multiple primary servers and there is likelihood that two virtual machines being replicated from different primary servers could have same name, or have virtual hard disks with the same name. Hence, the folder names are used as GUIDs to ensure uniqueness is maintained.
Instead of this default folder structure, you may want to have a simpler folder structure as you are sure that you will not get such name conflicts in your setup. You may want a folder structure that looks like:
The good news is that you can achieve this using simple steps . Here are the steps that could accomplish this for you:
Enable replication for the virtual machine, and ensure initial replication is not started immediately (You can choose to schedule the initial replication for a later time)
Once Replica virtual machine is created, use the Move wizard to move the storage of the virtual machine to the path of your choice (Storage migration)
Once the storage migration is complete, you can start the initial replication for the virtual machine
You can do the same steps using Powershell. Here is a sample script that accomplishes this task for you. This script assumes both primary and replica sides to be clustered setups. This script also assumes certificate-based authentication being used. You can easily customize the script if you have a different environment.
Once you run this script on you primary cluster, you will get a function that can then be used to enable replication to get the desired folder structure on the Replica cluster. Here is an example usage for this script:
Here MySeattleCluster is the name of the primary cluster, MyLondonCluster is the name of the replica cluster, and MyLondonCluster authorizes MySeattleCluster to replicate by an authorization entry where AllowedPrimaryServer value is MySeattleBroker.contoso.com
The certificate for replication is queried from the installed certificates. The first certificate valid for replication is picked. If you want to explicitly specify a certificate, you can replace $PersonalCert.Thumbprint used in the Enable-Replication cmdlet to the thumbprint of the certificate you want to use.
Here is a sample script for stand-alone primary replicating to stand-alone replica server using kerberos authentication:
For both these scripts, if your Replica side allows any authenticated server to replicate, as opposed to allowing specific servers, you should skip the AllowedPrimaryServer parameter. The script will then use the default storage location returned by the Get-VMReplicationServer cmdlet as the base path for creating the Replica virtual machine files.
Here are some cmdlets that will help you query how you have set up the Replica side for allowing incoming replication:
On the Replica side, you could have authorized all authenticated servers to replicate, in which case the location where Replica virtual machine files will get created can be queried using the Get-VMReplicationServer cmdlet:
If the ReplicationAllowedFromAnyServer value returned by this cmdlet is FALSE, then you have chosen to allow only specific primary servers to replicate to the given Replica server (or cluster). In this case, the default location for creating Replica virtual machine files can be queried using the Get-VMReplicationAuthorizationEntry:
This will return all authorization entries on the specified Replica server. To query the authorization entry corresponding to a specific primary server, you can filter the query using the –AllowedPrimaryServer parameter. Specify the value that corresponds to the primary server from which you would be replicating virtual machines, e.g.,
You can customize the scripts are per your specific setup. Keep watching this space for more such utility scripts.