![]() |
VOOZH | about |
The CData Cmdlets for Outreach.io 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 Outreach.io.
The Cmdlets are not only a PowerShell interface to Outreach.io, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Outreach.io data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Outreach.io. To access Outreach.io data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Outreach.io.
Once you have acquired the necessary connection properties, accessing Outreach.io data in PowerShell can be enabled in three steps.
You must use OAuth to authenticate with Outreach. Set the InitiateOAuth connection property to "GETANDREFRESH". For more information, refer to the OAuth section in the Help documentation.
Install the module:
Install-Module OutreachCmdlets
Connect:
$outreach = Connect-Outreach -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$industry = "Textiles" $accounts = Select-Outreach -Connection $outreach -Table "Accounts" -Where "Industry = `'$Industry`'" $accounts
You can also use the Invoke-Outreach cmdlet to execute SQL commands:
$accounts = Invoke-Outreach -Connection $outreach -Query 'SELECT * FROM Accounts WHERE Industry = @Industry' -Params @{'@Industry'='Textiles'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Outreach.io\lib\System.Data.CData.Outreach.dll")
Connect to Outreach.io:
$conn= New-Object System.Data.CData.Outreach.OutreachConnection("InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the OutreachDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, NumberOfEmployees from Accounts"
$da= New-Object System.Data.CData.Outreach.OutreachDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.name $_.numberofemployees
}
Update-Outreach -Connection $Outreach -Columns @('Name','NumberOfEmployees') -Values @('MyName', 'MyNumberOfEmployees') -Table Accounts -Id "MyId"
$cmd = New-Object System.Data.CData.Outreach.OutreachCommand("UPDATE Accounts SET Industry='Textiles' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Outreach.OutreachParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-Outreach -Connection $Outreach -Table Accounts -Columns @("Name", "NumberOfEmployees") -Values @("MyName", "MyNumberOfEmployees")
$cmd = New-Object System.Data.CData.Outreach.OutreachCommand("INSERT INTO Accounts (Industry) VALUES (@myIndustry)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Outreach.OutreachParameter("@myIndustry","Textiles")))
$cmd.ExecuteNonQuery()
Remove-Outreach -Connection $Outreach -Table "Accounts" -Id "MyId"
$cmd = New-Object System.Data.CData.Outreach.OutreachCommand("DELETE FROM Accounts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Outreach.OutreachParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Outreach.io Data Provider to get started:
Download NowLearn more:
👁 Outreach.io IconRapidly create and deploy powerful .NET applications that integrate with Outreach.io.