Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Automate Act CRM Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Act CRM data from PowerShell? This article demonstrates how to utilize the Act CRM Cmdlets for tasks like connecting to Act CRM data, automating operations, downloading data, and more.
The CData Cmdlets for Act CRM 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 Act CRM.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Act CRM, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Act CRM data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Act CRM. To access Act CRM data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Act CRM.
Once you have acquired the necessary connection properties, accessing Act CRM data in PowerShell can be enabled in three steps.
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.
PowerShell
-
Install the module:
Install-Module ActCRMCmdlets
-
Connect:
$actcrm = Connect-ActCRM -URL "$URL" -User "$User" -Password "$Password" -ActDatabase "$ActDatabase"
-
Search for and retrieve data:
$subject = "Sample subject" $activities = Select-ActCRM -Connection $actcrm -Table "Activities" -Where "Subject = `'$Subject`'" $activities
You can also use the Invoke-ActCRM cmdlet to execute SQL commands:
$activities = Invoke-ActCRM -Connection $actcrm -Query 'SELECT * FROM Activities WHERE Subject = @Subject' -Params @{'@Subject'='Sample subject'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Act CRM\lib\System.Data.CData.ActCRM.dll")
-
Connect to Act CRM:
$conn= New-Object System.Data.CData.ActCRM.ActCRMConnection("URL=https://myActCRMserver.com;User=myUser;Password=myPassword;ActDatabase=MyDB;") $conn.Open()
-
Instantiate the ActCRMDataAdapter, execute an SQL query, and output the results:
$sql="SELECT ActivityDisplayName, Subject from Activities" $da= New-Object System.Data.CData.ActCRM.ActCRMDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.activitydisplayname $_.subject }
Update Act CRM Data
PowerShell
Update-ActCRM -Connection $ActCRM -Columns @('ActivityDisplayName','Subject') -Values @('MyActivityDisplayName', 'MySubject') -Table Activities -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.ActCRM.ActCRMCommand("UPDATE Activities SET Subject='Sample subject' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ActCRM.ActCRMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Insert Act CRM Data
PowerShell
Add-ActCRM -Connection $ActCRM -Table Activities -Columns @("ActivityDisplayName", "Subject") -Values @("MyActivityDisplayName", "MySubject")
ADO.NET
$cmd = New-Object System.Data.CData.ActCRM.ActCRMCommand("INSERT INTO Activities (Subject) VALUES (@mySubject)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ActCRM.ActCRMParameter("@mySubject","Sample subject")))
$cmd.ExecuteNonQuery()
Delete Act CRM Data
PowerShell
Remove-ActCRM -Connection $ActCRM -Table "Activities" -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.ActCRM.ActCRMCommand("DELETE FROM Activities WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ActCRM.ActCRMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject