Ready to get started?

Download a free trial of the HCL Domino Cmdlets to get started:

 Download Now

Learn more:

HCL Domino Icon HCL Domino Data Cmdlets

An easy-to-use set of PowerShell Cmdlets offering real-time access to HCL Domino. The Cmdlets allow users to easily read, write, update, and delete live data - just like working with SQL server.

PowerShell Scripting to Replicate HCL Domino Data to MySQL



Write a simple PowerShell script to replicate HCL Domino data to a MySQL database.

The CData Cmdlets for HCL Domino offer live access to HCL Domino data from within PowerShell. Using PowerShell scripts, you can easily automate regular tasks like data replication. This article will walk through using the CData Cmdlets for HCL Domino and the CData Cmdlets for MySQL in PowerShell to replicate HCL Domino data to a MySQL database.

After obtaining the needed connection properties, accessing HCL Domino data in PowerShell and preparing for replication consists of four basic steps.

Prerequisites

The connector requires the Proton component to be installed. Normally, Proton is distributed as part of the AppDev pack. See the HCL documentation for instructions on acquiring and installing Proton or the AppDev pack.

Once the Proton service is installed and running, you will also need to create a user account and download its Internet certificate. This certificate can be used to set the connector certificate connection properties.

Authenticating to Domino

  • Server: The name or IP address of the server running Domino with the Proton service.
  • Port: The port number that the Proton service is listening on.
  • Database: The name of the database file, including the .nsf extension.
  • SSLClientCertType: This must match the format of the certificate file. Typically this will be either PEMKEY_FILE for .pem certificates or PFXFILE for .pfx certificates.
  • SSLClientCert: The path to the certificate file.
  • SSLServerCert: This can be set to (*) if you trust the server. This is usually the case, but if you want to perform SSL validation, you may provide a certificate or thumbprint instead. See the documentation for SSLServerCert for details.

Additional Server Configuration

The connector supports querying Domino views if any are defined. Before views can be queried by the connector they must be registered with the design catalog.

Please refer to the Catalog Administration section of the AppDev pack documentation for details on how to do this.

Collecting HCL Domino Data

  1. Install the module:

    Install-Module DominoCmdlets
  2. Connect to HCL Domino:

    $domino = Connect-Domino -Server $Server -Database $Database -Port $Port -SSLClientCertType $SSLClientCertType -SSLClientCert $SSLClientCert -SSLServerCert $SSLServerCert
  3. Retrieve the data from a specific resource:

    $data = Select-Domino -Connection $domino -Table "ByName"

    You can also use the Invoke-Domino cmdlet to execute pure SQL-92 statements:

    $data = Invoke-Domino -Connection $domino -Query 'SELECT * FROM ByName WHERE City = @City' -Params @{'@City'='Miami'}
  4. Save a list of the column names from the returned data.

    $columns = ($data | Get-Member -MemberType NoteProperty | Select-Object -Property Name).Name

Inserting HCL Domino Data into the MySQL Database

With the data and column names collected, you are ready to replicate the data into a MySQL database.

  1. Install the module:

    Install-Module MySQLCmdlets
  2. Connect to MySQL, using the server address and port of the MySQL server, valid user credentials, and a specific database with the table in which the data will be replicated:

    $mysql = Connect-MySQL -User $User -Password $Password -Database $Database -Server $Server -Port $Port
  3. Loop through the HCL Domino data, store the values, and use the Add-MySQL cmdlet to insert the data into the MySQL database, one row at a time. In this example, the table will need to have the same name as the HCL Domino resource (ByName) and to exist in the database.

    $data | % { $row = $_ $values = @() $columns | % { $col = $_ $values += $row.$($col) } Add-MySQL -Connection $mysql -Table "ByName" -Columns $columns -Values $values }

You have now replicated your HCL Domino data to a MySQL database. This gives you freedom to work with HCL Domino data in the same way that you work with other MySQL tables, whether that is performing analytics, building reports, or other business functions.

Notes

  • Once you have connected to HCL Domino and MySQL in PowerShell, you can pipe command results to perform the replication in a single line:

    Select-Domino -Connection $domino -Table "ByName" | % { $row = $_ $values = @() $columns | % { $col = $_ $values += $row.$($col) } Add-MySQL -Connection $mysql -Table "ByName" -Columns $columns -Values $values }
  • If you wish to replicate the HCL Domino data to another database using another PowerShell module, you will want to exclude the Columns, Connection, and Table columns from the data returned by the Select-Domino cmdlet since those columns are used to help pipe data from one CData cmdlet to another:

    $columns = ($data | Get-Member -MemberType NoteProperty | Select-Object -Property Name).Name | ? {$_ -NotIn @('Columns','Connection','Table')}