Pipe Epicor Kinetic Data to CSV in PowerShell

Ready to get started?

Download a free trial of the Epicor Kinetic Cmdlets to get started:

 Download Now

Learn more:

Epicor Kinetic Icon Epicor Kinetic Cmdlets

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

Use standard PowerShell cmdlets to access Epicor Kinetic tables.

The CData Cmdlets Module for Epicor Kinetic is a standard PowerShell module offering straightforward integration with Epicor Kinetic. Below, you will find examples of using our epicorKinetic Cmdlets with native PowerShell cmdlets.

Creating a Connection to Your Epicor Kinetic Data

To successfully connect to your ERP instance, you must specify the following connection properties:

  • Url:the URL of the server hosting your ERP instance. For example, https://myserver.EpicorSaaS.com
  • ERPInstance: the name of your ERP instance.
  • User: the username of your account.
  • Password: the password of your account.
  • Service: the service you want to retrieve data from. For example, BaqSvc.

In addition, you may also set the optional connection properties:

  • ApiKey: An optional key that may be required for connection to some services depending on your account configuration.
  • ApiVersion: Defaults to v1. May be set to v2 to use the newer Epicor API.
  • Company: Required if you set the ApiVersion to v2.

$conn = Connect-epicorKinetic  -Service "$Service" -ERPInstance "$ERPInstance" -URL "$URL" -User "$User" -Password "$Password"

Selecting Data

Follow the steps below to retrieve data from the Customers table and pipe the result into to a CSV file:

Select-epicorKinetic -Connection $conn -Table Customers | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myCustomersData.csv -NoTypeInformation

You will notice that we piped the results from Select-epicorKinetic into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.

The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.

Deleting Data

The following line deletes any records that match the criteria:

Select-epicorKinetic -Connection $conn -Table Customers -Where "CompanyName = CompanyName" | Remove-epicorKinetic

Inserting and Updating Data

The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into Epicor Kinetic, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyCustomersUpdates.csv | %{
  $record = Select-epicorKinetic -Connection $epicorKinetic -Table Customers -Where ("Id = `'"+$_.Id+"`'")
    Update-epicorKinetic -Connection $epicorkinetic -Table Customers -Columns ("CustNum","Company") -Values ($_.CustNum, $_.Company) -Where ("Id = `'"+$_.Id+"`'")
    Add-epicorKinetic -Connection $epicorkinetic -Table Customers -Columns ("CustNum","Company") -Values ($_.CustNum, $_.Company)

As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!