Ready to get started?

Learn more about the Act CRM PowerShell Cmdlets or download a free trial:

Download Now

Pipe Act CRM Data to CSV in PowerShell

Use standard PowerShell cmdlets to access Act CRM tables.

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

Creating a Connection to Your Act CRM Data

The User and Password properties, under the Authentication section, must be set to valid Act! user credentials. In addition to the authentication values, see the following:

  • Connecting to Act! Premium

    In addition to the authentication values, the URL to Act! is also required; for example https://eup1-iis-04.eu.hosted.act.com/.

    Additionally, you must specify the ActDatabase you will connect to. This is found by going to the About Act! Premium menu of your account, at the top right of the page, in the ? menu. Use the Database Name in the window that appears.

  • Connecting to Act! Premium Cloud

    To connect to your Act! Premium Cloud account, you also need to specify the ActCloudName property. This property is found in the URL address of the Cloud account; for example https://eup1-iis-04.eu.hosted.act.com/ActCloudName/.

Note that retrieving ActCRM metadata can be expensive. It is advised that you set the CacheMetadata property to store the metadata locally.

$conn = Connect-ActCRM  -URL "$URL" -User "$User" -Password "$Password" -ActDatabase "$ActDatabase"

Selecting Data

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

Select-ActCRM -Connection $conn -Table Activities | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myActivitiesData.csv -NoTypeInformation

You will notice that we piped the results from Select-ActCRM 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-ActCRM -Connection $conn -Table Activities -Where "Subject = Sample subject" | Remove-ActCRM

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 Act CRM, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyActivitiesUpdates.csv | %{
  $record = Select-ActCRM -Connection $ActCRM -Table Activities -Where ("Id = `'"+$_.Id+"`'")
  if($record){
    Update-ActCRM -Connection $actcrm -Table Activities -Columns ("ActivityDisplayName","Subject") -Values ($_.ActivityDisplayName, $_.Subject) -Where ("Id = `'"+$_.Id+"`'")
  }else{
    Add-ActCRM -Connection $actcrm -Table Activities -Columns ("ActivityDisplayName","Subject") -Values ($_.ActivityDisplayName, $_.Subject)
  }
}

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!