![]() |
VOOZH | about |
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.
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 and 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 to Act! is also required; for example https://eup1-iis-04.eu.hosted.act.com/.
Additionally, you must specify the 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 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 property to store the metadata locally.
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'}
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-ActCRM -Connection $ActCRM -Columns @('ActivityDisplayName','Subject') -Values @('MyActivityDisplayName', 'MySubject') -Table Activities -Id "MyId"
$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()
Add-ActCRM -Connection $ActCRM -Table Activities -Columns @("ActivityDisplayName", "Subject") -Values @("MyActivityDisplayName", "MySubject")
$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()
Remove-ActCRM -Connection $ActCRM -Table "Activities" -Id "MyId"
$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
Download a free trial of the Act CRM Data Provider to get started:
Download NowLearn more:
👁 Act CRM IconRapidly create and deploy powerful .NET applications that integrate with Act CRM data including Companies, Contact, Groups, Opportunities, and more!