Automate Kintone Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Kintone data from PowerShell? This article demonstrates how to utilize the Kintone Cmdlets for tasks like connecting to Kintone data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Kintone is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Kintone.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Kintone; this tutorial shows how to use the Provider to create, retrieve, update, and delete Kintone data.

Once you have acquired the necessary connection properties, accessing Kintone data in PowerShell can be enabled in three steps.

In addition to the authentication values, set the following parameters to connect to and retrieve data from Kintone:

  • Url: The URL of your account.
  • GuestSpaceId: Optional. Set this when using a guest space.

Authenticating with Kintone

Kintone supports the following authentication methods.

Using Password Authentication

You must set the following to authenticate:

  • User: The username of your account.
  • Password: The password of your account.

Using Basic Authentication

If the basic authentication security feature is set on the domain, supply the additional login credentials with BasicAuthUser and BasicAuthPassword. Basic authentication requires these credentials in addition to User and Password.

Using Client SSL

Instead of basic authentication, you can specify a client certificate to authenticate. Set SSLClientCert, SSLClientCertType, SSLClientCertSubject, and SSLClientCertPassword. Additionally, set User and Password to your login credentials.

  1. Load the provider's assembly:

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

     
    $conn= New-Object System.Data.CData.Kintone.KintoneConnection("User=myuseraccount;Password=mypassword;Url=http://subdomain.domain.com;GuestSpaceId=myspaceid")
    $conn.Open()
    
  3. Instantiate the KintoneDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT CreatorName, Text from Comments"
    
    $da= New-Object System.Data.CData.Kintone.KintoneDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.creatorname $_.text
    }
      

Update Kintone Data


$cmd =  New-Object System.Data.CData.Kintone.KintoneCommand("UPDATE Comments SET AppId='1354841' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Kintone.KintoneParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Kintone Data


$cmd =  New-Object System.Data.CData.Kintone.KintoneCommand("INSERT INTO Comments (AppId) VALUES (@myAppId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Kintone.KintoneParameter("@myAppId","1354841")))
$cmd.ExecuteNonQuery()

Delete Kintone Data


$cmd =  New-Object System.Data.CData.Kintone.KintoneCommand("DELETE FROM Comments WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Kintone.KintoneParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Kintone Data Provider to get started:

 Download Now

Learn more:

Kintone  Icon Kintone ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Kintone.