Automate Zoho CRM Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Zoho CRM ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Zoho CRM account data including Leads, Contacts, Opportunities, Accounts, and more!



Are you looking for a quick and easy way to access Zoho CRM data from PowerShell? We show how to use the Cmdlets for Zoho CRM and the CData ADO.NET Provider for Zoho CRM to connect to Zoho CRM data and synchronize, automate, download, and more.

The CData Cmdlets for Zoho 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 Zoho CRM.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Zoho CRM API, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Zoho CRM data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Zoho CRM. To access Zoho CRM data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Zoho CRM.

After obtaining the needed connection properties, accessing Zoho CRM data in PowerShell consists of three basic steps.

You will need to obtain an AuthToken to authenticate to Zoho CRM. You can generate an AuthToken on the Zoho CRM website or by calling the GetAuthToken stored procedure. Note that when you generate an AuthToken from Zoho CRM, you can only generate an AuthToken for your user account. You can generate AuthTokens for other user accounts by calling GetAuthToken.

See the "Getting Started" chapter in the help documentation for a guide.

PowerShell

  1. Install the module:

    Install-Module ZohoCRMCmdlets
  2. Connect:

    $zohocrm = Connect-Zoho -AuthToken "$AuthToken"
  3. Search for and retrieve data:

    $industry = "Data/Telecom OEM" $accounts = Select-Zoho -Connection $zohocrm -Table "Accounts" -Where "Industry = `'$Industry`'" $accounts

    You can also use the Invoke-Zoho cmdlet to execute SQL commands:

    $accounts = Invoke-Zoho -Connection $zohocrm -Query 'SELECT * FROM Accounts WHERE Industry = @Industry' -Params @{'@Industry'='Data/Telecom OEM'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.ZohoCRM.ZohoCRMConnection("AuthToken=2ad3b3e719f6bed7368e5e7e26e4f988;") $conn.Open()
  3. Instantiate the ZohoCRMDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Account_Name, Annual_Revenue from Accounts" $da= New-Object System.Data.CData.ZohoCRM.ZohoCRMDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.account_name $_.annual_revenue }

Update Zoho CRM Data

PowerShell

Update-Zoho -Connection $ZohoCRM -Columns @('Account_Name','Annual_Revenue') -Values @('MyAccount_Name', 'MyAnnual_Revenue') -Table Accounts -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("UPDATE Accounts SET Industry='Data/Telecom OEM' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.ZohoCRM.ZohoCRMParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Zoho CRM Data

PowerShell

Add-Zoho -Connection $ZohoCRM -Table Accounts -Columns @("Account_Name", "Annual_Revenue") -Values @("MyAccount_Name", "MyAnnual_Revenue")

ADO.NET

$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("INSERT INTO Accounts (Industry) VALUES (@myIndustry)", $conn) $cmd.Parameters.Add(new System.Data.CData.ZohoCRM.ZohoCRMParameter("@myIndustry","Data/Telecom OEM")) $cmd.ExecuteNonQuery()

Delete Zoho CRM Data

PowerShell

Remove-Zoho -Connection $ZohoCRM -Table "Accounts" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ZohoCRM.ZohoCRMCommand("DELETE FROM Accounts WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.ZohoCRM.ZohoCRMParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()