![]() |
VOOZH | about |
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.
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:
In addition, you may also set the optional connection properties:
Install the module:
Install-Module EpicorERPCmdlets
Connect:
$epicorerp = Connect-EpicorERP -Service "$Service" -ERPInstance "$ERPInstance" -URL "$URL" -User "$User" -Password "$Password" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$companyname = "CompanyName" $customers = Select-EpicorERP -Connection $epicorerp -Table "Customers" -Where "CompanyName = `'$CompanyName`'" $customers
You can also use the Invoke-EpicorERP cmdlet to execute SQL commands:
$customers = Invoke-EpicorERP -Connection $epicorerp -Query 'SELECT * FROM Customers WHERE CompanyName = @CompanyName' -Params @{'@CompanyName'='CompanyName'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Epicor Kinetic\lib\System.Data.CData.EpicorERP.dll")
Connect to Epicor Kinetic:
$conn= New-Object System.Data.CData.EpicorERP.EpicorERPConnection("Service=Erp.BO.CustomerSvc;ERPInstance=MyInstance;URL=https://myaccount.epicorsaas.com;User=username;Password=password;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the EpicorERPDataAdapter, execute an SQL query, and output the results:
$sql="SELECT CustNum, Company from Customers"
$da= New-Object System.Data.CData.EpicorERP.EpicorERPDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.custnum $_.company
}
Update-EpicorERP -Connection $EpicorERP -Columns @('CustNum','Company') -Values @('MyCustNum', 'MyCompany') -Table Customers -Id "MyId"
$cmd = New-Object System.Data.CData.EpicorERP.EpicorERPCommand("UPDATE Customers SET CompanyName='CompanyName' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.EpicorERP.EpicorERPParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-EpicorERP -Connection $EpicorERP -Table Customers -Columns @("CustNum", "Company") -Values @("MyCustNum", "MyCompany")
$cmd = New-Object System.Data.CData.EpicorERP.EpicorERPCommand("INSERT INTO Customers (CompanyName) VALUES (@myCompanyName)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.EpicorERP.EpicorERPParameter("@myCompanyName","CompanyName")))
$cmd.ExecuteNonQuery()
Remove-EpicorERP -Connection $EpicorERP -Table "Customers" -Id "MyId"
$cmd = New-Object System.Data.CData.EpicorERP.EpicorERPCommand("DELETE FROM Customers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.EpicorERP.EpicorERPParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Epicor Kinetic Data Provider to get started:
Download NowLearn more:
👁 Epicor Kinetic IconRapidly create and deploy powerful .NET applications that integrate with Epicor Kinetic data, including Sales Orders, Purchase Orders, Accounts, and more!