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 Kintone Integration Tasks from PowerShell
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 Cmdlets for Kintone 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 Kintone.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Kintone, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Kintone data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Kintone. To access Kintone data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Kintone.
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.
PowerShell
-
Install the module:
Install-Module KintoneCmdlets
-
Connect:
$kintone = Connect-Kintone -User "$User" -Password "$Password" -Url "$Url" -GuestSpaceId "$GuestSpaceId"
-
Search for and retrieve data:
$appid = "1354841" $comments = Select-Kintone -Connection $kintone -Table "Comments" -Where "AppId = `'$AppId`'" $comments
You can also use the Invoke-Kintone cmdlet to execute SQL commands:
$comments = Invoke-Kintone -Connection $kintone -Query 'SELECT * FROM Comments WHERE AppId = @AppId' -Params @{'@AppId'='1354841'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Kintone\lib\System.Data.CData.Kintone.dll")
-
Connect to Kintone:
$conn= New-Object System.Data.CData.Kintone.KintoneConnection("User=myuseraccount;Password=mypassword;Url=http://subdomain.domain.com;GuestSpaceId=myspaceid") $conn.Open()
-
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
PowerShell
Update-Kintone -Connection $Kintone -Columns @('CreatorName','Text') -Values @('MyCreatorName', 'MyText') -Table Comments -Id "MyId"
ADO.NET
$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
PowerShell
Add-Kintone -Connection $Kintone -Table Comments -Columns @("CreatorName", "Text") -Values @("MyCreatorName", "MyText")
ADO.NET
$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
PowerShell
Remove-Kintone -Connection $Kintone -Table "Comments" -Id "MyId"
ADO.NET
$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()
CodeProject