Ready to get started?

Learn more about the CData ADO.NET Provider for HPCC or download a free trial:

Download Now

Automate HPCC Systems Integration Tasks from PowerShell

Are you looking for a quick and easy way to access HPCC Systems data from PowerShell? We show how to use the Cmdlets for HPCC Systems and the CData ADO.NET Provider for HPCC Systems to connect to HPCC Systems data and synchronize, automate, download, and more.

The CData Cmdlets for HPCC Systems are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to HPCC Systems.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the HPCC Systems API, but also an SQL interface; this tutorial shows how to use both to retrieve HPCC Systems data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for HPCC Systems. To access HPCC Systems data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for HPCC Systems.

After obtaining the needed connection properties, accessing HPCC Systems data in PowerShell consists of three basic steps.

To connect, set the following connection properties: Set URL to the machine name or IP address of the server and the port the server is running on, for example, https://server:port. The User and Password are required to authenticate to the HPCC Systems cluster specified in the URL. Note that LDAP authentication is not currently supported by our ODBC driver.

Set Version to the WsSQL Web server version. Note that if you have not already done so, you will need to install the WsSQL service on the HPCC Systems server. The WsSQL Web service is used to interact with the underlying HPCC Systems platform.

Set Cluster to the target cluster.

PowerShell

  1. Install the module:

    Install-Module HPCCCmdlets
  2. Connect:

    $hpcc = Connect-HPCC -URL "$URL" -User "$User" -password "$password" -Version "$Version" -Cluster "$Cluster"
  3. Search for and retrieve data:

    $shipcity = "New York" $hpcc::test::orders = Select-HPCC -Connection $hpcc -Table "hpcc::test::orders" -Where "ShipCity = `'$ShipCity`'" $hpcc::test::orders

    You can also use the Invoke-HPCC cmdlet to execute SQL commands:

    $hpcc::test::orders = Invoke-HPCC -Connection $hpcc -Query 'SELECT * FROM hpcc::test::orders WHERE ShipCity = @ShipCity' -Params @{'@ShipCity'='New York'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for HPCC Systems\lib\System.Data.CData.HPCC.dll")
  2. Connect to HPCC Systems:

    $conn= New-Object System.Data.CData.HPCC.HPCCConnection("URL=http://127.0.0.1:8510;User=test;password=xA123456;Version=1;Cluster=hthor;") $conn.Open()
  3. Instantiate the HPCCDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT CustomerName, Price from hpcc::test::orders" $da= New-Object System.Data.CData.HPCC.HPCCDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.customername $_.price }