Ready to get started?

Learn more about the or download a free trial:

Download Now

Pipe Dynamics GP Data to CSV in PowerShell

Use standard PowerShell cmdlets to access Dynamics GP tables.

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

Creating a Connection to Your Dynamics GP Data

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.

$conn = Connect-DynamicsGP  -CompanyId "$CompanyId" -user "$user" -password "$password" -URL "$URL"

Selecting Data

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

Select-DynamicsGP -Connection $conn -Table SalesInvoice | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\mySalesInvoiceData.csv -NoTypeInformation

You will notice that we piped the results from Select-DynamicsGP 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.