![]() |
VOOZH | about |
The CData Cmdlets for Certinia 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 Certinia.
The Cmdlets are not only a PowerShell interface to Certinia, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Certinia data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Certinia. To access Certinia data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Certinia.
Once you have acquired the necessary connection properties, accessing Certinia data in PowerShell can be enabled in three steps.
There are several authentication methods available for connecting to Certinia: login credentials, SSO, and OAuth.
Set the User and Password to your login credentials. Additionally, set the SecurityToken. By default, the SecurityToken is required, but you can make it optional by allowing a range of trusted IP addresses.
To disable the security token:
To obtain the security token:
If you do not have access to the user name and password or do not want to require them, use the OAuth user consent flow. See the OAuth section in the Help for an authentication guide.
Set UseSandbox to true (false by default) to use a Certinia sandbox account. Ensure that you specify a sandbox user name in User.
Install the module:
Install-Module CertiniaCmdlets
Connect:
$certinia = Connect-Certinia -User "$User" -Password "$Password" -Security Token "$Security Token" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$industry = "Floppy Disks" $account = Select-Certinia -Connection $certinia -Table "Account" -Where "Industry = `'$Industry`'" $account
You can also use the Invoke-Certinia cmdlet to execute SQL commands:
$account = Invoke-Certinia -Connection $certinia -Query 'SELECT * FROM Account WHERE Industry = @Industry' -Params @{'@Industry'='Floppy Disks'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Certinia\lib\System.Data.CData.Certinia.dll")
Connect to Certinia:
$conn= New-Object System.Data.CData.Certinia.CertiniaConnection("User=myUser;Password=myPassword;Security Token=myToken;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the CertiniaDataAdapter, execute an SQL query, and output the results:
$sql="SELECT BillingState, Name from Account"
$da= New-Object System.Data.CData.Certinia.CertiniaDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.billingstate $_.name
}
Update-Certinia -Connection $Certinia -Columns @('BillingState','Name') -Values @('MyBillingState', 'MyName') -Table Account -Id "MyId"
$cmd = New-Object System.Data.CData.Certinia.CertiniaCommand("UPDATE Account SET Industry='Floppy Disks' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Certinia.CertiniaParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-Certinia -Connection $Certinia -Table Account -Columns @("BillingState", "Name") -Values @("MyBillingState", "MyName")
$cmd = New-Object System.Data.CData.Certinia.CertiniaCommand("INSERT INTO Account (Industry) VALUES (@myIndustry)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Certinia.CertiniaParameter("@myIndustry","Floppy Disks")))
$cmd.ExecuteNonQuery()
Remove-Certinia -Connection $Certinia -Table "Account" -Id "MyId"
$cmd = New-Object System.Data.CData.Certinia.CertiniaCommand("DELETE FROM Account WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Certinia.CertiniaParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Certinia Data Provider to get started:
Download NowLearn more:
👁 Certinia IconRapidly create and deploy powerful .NET applications that integrate with Certinia.