Ready to get started?

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

 Download Now

Learn more:

Epicor Kinetic Icon Epicor Kinetic ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Epicor Kinetic data, including Sales Orders, Purchase Orders, Accounts, and more!

Automate Epicor Kinetic Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Epicor Kinetic data from PowerShell? This article demonstrates how to utilize the Epicor Kinetic Cmdlets for tasks like connecting to Epicor Kinetic data, automating operations, downloading data, and more.

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

PowerShell Cmdlets or ADO.NET Provider?

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

Once you have acquired the necessary connection properties, accessing Epicor Kinetic data in PowerShell can be enabled in three steps.

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.

PowerShell

  1. Install the module:

    Install-Module epicorKineticCmdlets
  2. Connect:

    $epicorkinetic = Connect-epicorKinetic -Service "$Service" -ERPInstance "$ERPInstance" -URL "$URL" -User "$User" -Password "$Password"
  3. Search for and retrieve data:

    $companyname = "CompanyName" $customers = Select-epicorKinetic -Connection $epicorkinetic -Table "Customers" -Where "CompanyName = `'$CompanyName`'" $customers

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

    $customers = Invoke-epicorKinetic -Connection $epicorkinetic -Query 'SELECT * FROM Customers WHERE CompanyName = @CompanyName' -Params @{'@CompanyName'='CompanyName'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.epicorKinetic.epicorKineticConnection("Service=Erp.BO.CustomerSvc;ERPInstance=MyInstance;URL=https://myaccount.epicorsaas.com;User=username;Password=password;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the epicorKineticDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT CustNum, Company from Customers" $da= New-Object System.Data.CData.epicorKinetic.epicorKineticDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.custnum $_.company }

Update Epicor Kinetic Data

PowerShell

Update-epicorKinetic -Connection $epicorKinetic -Columns @('CustNum','Company') -Values @('MyCustNum', 'MyCompany') -Table Customers -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.epicorKinetic.epicorKineticCommand("UPDATE Customers SET CompanyName='CompanyName' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.epicorKinetic.epicorKineticParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Epicor Kinetic Data

PowerShell

Add-epicorKinetic -Connection $epicorKinetic -Table Customers -Columns @("CustNum", "Company") -Values @("MyCustNum", "MyCompany")

ADO.NET

$cmd = New-Object System.Data.CData.epicorKinetic.epicorKineticCommand("INSERT INTO Customers (CompanyName) VALUES (@myCompanyName)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.epicorKinetic.epicorKineticParameter("@myCompanyName","CompanyName"))) $cmd.ExecuteNonQuery()

Delete Epicor Kinetic Data

PowerShell

Remove-epicorKinetic -Connection $epicorKinetic -Table "Customers" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.epicorKinetic.epicorKineticCommand("DELETE FROM Customers WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.epicorKinetic.epicorKineticParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()