![]() |
VOOZH | about |
The CData Cmdlets for Highrise 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 Highrise.
The Cmdlets are not only a PowerShell interface to Highrise, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Highrise data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Highrise. To access Highrise data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Highrise.
Once you have acquired the necessary connection properties, accessing Highrise data in PowerShell can be enabled in three steps.
Highrise uses the OAuth authentication standard. To authenticate to Highrise, obtain the OAuthClientId, OAuthClientSecret, and CallbackURL by registering an app with Highrise. You will also need to set the AccountId to connect to data.
See the "Getting Started" section in the help documentation for a guide to using OAuth.
Install the module:
Install-Module HighriseCmdlets
Connect:
$highrise = Connect-Highrise -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL" -AccountId "$AccountId" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$groupid = "MyGroupId" $deals = Select-Highrise -Connection $highrise -Table "Deals" -Where "GroupId = `'$GroupId`'" $deals
You can also use the Invoke-Highrise cmdlet to execute SQL commands:
$deals = Invoke-Highrise -Connection $highrise -Query 'SELECT * FROM Deals WHERE GroupId = @GroupId' -Params @{'@GroupId'='MyGroupId'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Highrise\lib\System.Data.CData.Highrise.dll")
Connect to Highrise:
$conn= New-Object System.Data.CData.Highrise.HighriseConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost;AccountId=MyAccountId;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the HighriseDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, Price from Deals"
$da= New-Object System.Data.CData.Highrise.HighriseDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.name $_.price
}
Update-Highrise -Connection $Highrise -Columns @('Name','Price') -Values @('MyName', 'MyPrice') -Table Deals -Id "MyId"
$cmd = New-Object System.Data.CData.Highrise.HighriseCommand("UPDATE Deals SET GroupId='MyGroupId' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Highrise.HighriseParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-Highrise -Connection $Highrise -Table Deals -Columns @("Name", "Price") -Values @("MyName", "MyPrice")
$cmd = New-Object System.Data.CData.Highrise.HighriseCommand("INSERT INTO Deals (GroupId) VALUES (@myGroupId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Highrise.HighriseParameter("@myGroupId","MyGroupId")))
$cmd.ExecuteNonQuery()
Remove-Highrise -Connection $Highrise -Table "Deals" -Id "MyId"
$cmd = New-Object System.Data.CData.Highrise.HighriseCommand("DELETE FROM Deals WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Highrise.HighriseParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Highrise Data Provider to get started:
Download NowLearn more:
👁 Highrise IconRapidly create and deploy powerful .NET applications that integrate with Highrise account data including Accounts, Deals, Emails, People, Tasks, and more!