Skip to content

Export IP Customization and convert

This guide will provide a method of exporting VM’s IP customization settings from the SRM database into an XML format using the dr-ip-reporter utility that’s included with all SRM installs and then taking this XML file and converting it into a more user friendly CSV file which can be viewed in EXCEL.

To start with there are a couple of things to note.
–          This will not work if the SRM service is not running.
–          You may need to change the port for the lookup service depending on what version the customer is running. (7444 / 7080 / 443)
–          I don’t know of any way of re-importing this information into the SRM database.
–          This is useful if a customer needs to reinstall SRM with a blank DB and doesn’t have a record of the VM’s IP customization details.

Step 1: Exporting the IP customization settings into XML format from the SRM database using the dr-ip-reporter.exe tool

Connect to the server running the SRM service.

1. Launch command prompt as administrator.
2. Type in:
cd “C:\Program Files\VMware\VMware vCenter Site Recovery Manager\bin”

3. Use the command below to obtain IP customization settings:

Information required:
–          IP Address or FQDN of the PSC
–          A location to store the xml output file

Capture IP details of all Plans:
dr-ip-reporter.exe –cfg “C:\Program Files\VMware\VMware vCenter Site Recovery Manager\config\vmware-dr.xml” –out “C:\Temp\IP-DR.xml” –uri “https://PSC-address:7444/lookupservice/sdk” -i -v

or

Specific Plan:
dr-ip-reporter.exe –cfg “C:\Program Files\VMware\VMware vCenter Site Recovery Manager\config\vmware-dr.xml” –out “C:\Temp\IP-DR.xml” –plan “RP Name” –uri “https://PSC-address:7444/lookupservice/sdk” -i –v

Note: The output of the xml file location is important as this will be used for converting the XML file to CSV. In this example we are outputting it to C:\Temp\IP-DR.xml

Explanation:
–out is the location of the output file
–plan is the name of the single recovery plan you want to export
–uri is the address of the vcenter lookup service

After running the command the user will be prompted for credential to log into the PSC, its recommended to use administrator@vsphere.local but any VC admin or member of the SSO admin group should work.

The XML output file looks like this:

Step 2: Converting the XML file to a CSV file so that it’s more user friendly.

Install VMware vSphere PowerCLI on the SRM server or alternatively copy the XML file to another system where powerCLI is installed. (This may also work in PowerShell but I have not tried)

Create a .ps1 file with the following contents:

Copy from below this line:

$filename = Read-host “Specify path to XML file” 

[xml]$input_file = Get-Content  $filename 
$output = $input_file.DrMappings.ProtectionGroups.ProtectionGroup | Sort Name | ForEach-Object { 
    $protection_group = $_.Name 
    $_.ProtectedVm | Sort Name | ForEach-Object { 
        $vm = $_.Name 
          
        $_.CustomizationSpec | Sort Site | ForEach-Object { 
            $site = $_.Site 
            $ip_settings = $_.ConfigRoot.e.ipSettings 
              
            if ($ip_settings) { 
                $ip_address = $ip_settings.ip.ipAddress 
                $subnetmask = $ip_settings.subnetMask 
                $gateway = $ip_settings.gateway.e.”#text” 
                  
                if ($ip_settings.dnsServerList.e) { 
                    $dns_server = [string]::Join(“,”, ($ip_settings.dnsServerList.e.”#text”)) 
                } 
            } 
  
            “” | Select @{N=”Protection Group”;E={$protection_group}}, 
                        @{N=”VM”;E={$vm}}, 
                        @{N=”Site”;E={$site}}, 
                        @{N=”IP Address”;E={$ip_address}}, 
                        @{N=”SubnetMask”;E={$subnetmask}}, 
                        @{N=”Gateway”;E={$gateway}}, 
                        @{N=”DNS Servers”;E={$dns_server}}
                         
            $ip_address = “”; 
            $subnetmask = “”; 
            $gateway = “”; 
            $dns_server = “”; 
        } 
    } 

  
$output | Export-Csv -UseCulture -NoTypeInformation srm_final_output.csv
.\srm_final_output.csv

Copy from above this line

Note: I’ve also attached this script to this email

Launch PowerCLI and change directory into the folder where the .ps1 script is located as below:

You will notice that I’ve placed the script in the same folder as I output the XML file from the previous step for ease of use.

Next we need to run the script to convert XML to CSV.

.\xmltocsv.ps1

After running the script a prompt will be returned. Enter the path to the XML file from Step 1. In my case this is C:\Temp\IP.xml and hit enter.

This creates a csv file in the same directory with the name srm_final_output.csv

Open this file in Excel to see the IP customization details note that VMs that do not have IP customization settings set will have blank values:

Information displayed:
Protection group name
VM Name
Site 1 / 2 or Production / DR
IP address
Subnet Mask
Gateway
DNS Servers

Some issues I’ve encountered:
–          Depending on the version of SRM the XML output may be in XML version 1.0 or 2.0. The powerCLI script will not work with XML version 2.0

Open the XML file and change the version from 2.0 to 1.0:

Categories

Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: