Ready to get started?

Download a free trial of the Dynamics GP Data Provider to get started:

 Download Now

Learn more:

Dynamics GP Icon Dynamics GP ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Dynamics GP data including Vendors, Customers, Invoices, Quotes, and more!

Automate Dynamics GP Integration Tasks from PowerShell



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

The CData ADO.NET Provider for Dynamics GP is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Dynamics GP.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Dynamics GP; this tutorial shows how to use the Provider to create, retrieve, update, and delete Dynamics GP data.

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

To authenticate set the User and Password connection properties.

To connect set the URL to the Web services endpoint; for example, http://{servername}:{port}/Dynamics/GPService. Additionally, set CompanyId; you can obtain this value in the company setup window: Click Tools -> Setup -> Company.

By default, data summaries are not returned to save performance. Set LookupIds to true to return details such as line items; however, note that entities must be retrieved one at a time.

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.DynamicsGP.DynamicsGPConnection("CompanyId=mycompanyId;user=myuser;password=mypassword;URL= http://{servername}:{port}/Dynamics/GPService;") $conn.Open()
  3. Instantiate the DynamicsGPDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT CustomerName, TotalAmount from SalesInvoice" $da= New-Object System.Data.CData.DynamicsGP.DynamicsGPDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.customername $_.totalamount }

Update Dynamics GP Data

$cmd = New-Object System.Data.CData.DynamicsGP.DynamicsGPCommand("UPDATE SalesInvoice SET CustomerName='Bob' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.DynamicsGP.DynamicsGPParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Dynamics GP Data

$cmd = New-Object System.Data.CData.DynamicsGP.DynamicsGPCommand("INSERT INTO SalesInvoice (CustomerName) VALUES (@myCustomerName)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.DynamicsGP.DynamicsGPParameter("@myCustomerName","Bob"))) $cmd.ExecuteNonQuery()

Delete Dynamics GP Data

$cmd = New-Object System.Data.CData.DynamicsGP.DynamicsGPCommand("DELETE FROM SalesInvoice WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.DynamicsGP.DynamicsGPParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()