Automate Reckon Accounts Hosted Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Reckon Accounts Hosted data from PowerShell? This article demonstrates how to utilize the Reckon Accounts Hosted Cmdlets for tasks like connecting to Reckon Accounts Hosted data, automating operations, downloading data, and more.

The CData Cmdlets for Reckon Accounts Hosted 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 Reckon Accounts Hosted.

PowerShell Cmdlets or ADO.NET Provider?

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

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

The connector makes requests to Reckon Accounts Hosted through OAuth. Specify the following connection properties:

  • SubscriptionKey: Required. You get this value when you created your developer account.
  • CountryVersion: Defaults to 2021.R2.AU.
  • CompanyFile: Required. The path to the company file.
  • User: Required. The username of the company file.
  • Password: Required. The password of the company file.
  • InitiateOAuth: Set this to GETANDREFRESH to let the driver handle access tokens.
  • CallbackURL: The redirectURI of your Custom OAuth App.
  • OAuthClientId: The client id of your Custom OAuth App.
  • OAuthClientSecret: The client secret of your Custom OAuth App.

CData provides an embedded OAuth application that simplifies OAuth desktop authentication. See the Help documentation for information on other OAuth authentication methods (web, headless, etc.), creating custom OAuth applications, and reasons for doing so.

PowerShell

  1. Install the module:

    Install-Module ReckonAccountsHostedCmdlets
  2. Connect:

    $reckonaccountshosted = Connect-ReckonAccountsHosted -SubscriptionKey "$SubscriptionKey" -CountryVersion "$CountryVersion" -CompanyFile "$CompanyFile" -User "$User" -Password "$Password" -CallbackURL "$CallbackURL" -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
  3. Search for and retrieve data:

    $isactive = "true" $accounts = Select-ReckonAccountsHosted -Connection $reckonaccountshosted -Table "Accounts" -Where "IsActive = `'$IsActive`'" $accounts

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

    $accounts = Invoke-ReckonAccountsHosted -Connection $reckonaccountshosted -Query 'SELECT * FROM Accounts WHERE IsActive = @IsActive' -Params @{'@IsActive'='true'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedConnection("SubscriptionKey=my_subscription_key;CountryVersion=2021.R2.AU;CompanyFile=Q:/CompanyName.QBW;User=my_user;Password=my_password;CallbackURL=http://localhost:33333;OAuthClientId=my_oauth_client_id;OAuthClientSecret=my_oauth_client_secret;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the ReckonAccountsHostedDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Name, Balance from Accounts" $da= New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.name $_.balance }

Update Reckon Accounts Hosted Data

PowerShell

Update-ReckonAccountsHosted -Connection $ReckonAccountsHosted -Columns @('Name','Balance') -Values @('MyName', 'MyBalance') -Table Accounts -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedCommand("UPDATE Accounts SET IsActive='true' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Reckon Accounts Hosted Data

PowerShell

Add-ReckonAccountsHosted -Connection $ReckonAccountsHosted -Table Accounts -Columns @("Name", "Balance") -Values @("MyName", "MyBalance")

ADO.NET

$cmd = New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedCommand("INSERT INTO Accounts (IsActive) VALUES (@myIsActive)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedParameter("@myIsActive","true"))) $cmd.ExecuteNonQuery()

Delete Reckon Accounts Hosted Data

PowerShell

Remove-ReckonAccountsHosted -Connection $ReckonAccountsHosted -Table "Accounts" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedCommand("DELETE FROM Accounts WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ReckonAccountsHosted.ReckonAccountsHostedParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the Reckon Accounts Hosted Data Provider to get started:

 Download Now

Learn more:

Reckon Accounts Hosted Icon Reckon Accounts Hosted ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Reckon Accounts Hosted.