![]() |
VOOZH | about |
The CData Cmdlets for Cvent 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 Cvent.
The Cmdlets are not only a PowerShell interface to Cvent, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Cvent data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Cvent. To access Cvent data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Cvent.
Once you have acquired the necessary connection properties, accessing Cvent data in PowerShell can be enabled in three steps.
Before you can authenticate to Cvent, you must create a workspace and an OAuth application.
To create a workspace:
| event/attendees:read | event/attendees:write | event/contacts:read |
| event/contacts:write | event/custom-fields:read | event/custom-fields:write |
| event/events:read | event/events:write | event/sessions:delete |
| event/sessions:read | event/sessions:write | event/speakers:delete |
| event/speakers:read | event/speakers:write | budget/budget-items:read |
| budget/budget-items:write | exhibitor/exhibitors:read | exhibitor/exhibitors:write |
| survey/surveys:read | survey/surveys:write |
After you have set up a Workspace and invited them, developers can sign up and create a custom OAuth app. See the Creating a Custom OAuth Application section in the Help documentation for more information.
After creating an OAuth application, set the following connection properties to connect to Cvent:
Install the module:
Install-Module CventCmdlets
Connect:
$cvent = Connect-Cvent -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$virtual = "true" $events = Select-Cvent -Connection $cvent -Table "Events" -Where "Virtual = `'$Virtual`'" $events
You can also use the Invoke-Cvent cmdlet to execute SQL commands:
$events = Invoke-Cvent -Connection $cvent -Query 'SELECT * FROM Events WHERE Virtual = @Virtual' -Params @{'@Virtual'='true'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Cvent\lib\System.Data.CData.Cvent.dll")
Connect to Cvent:
$conn= New-Object System.Data.CData.Cvent.CventConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the CventDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, Title from Events"
$da= New-Object System.Data.CData.Cvent.CventDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.title
}
Update-Cvent -Connection $Cvent -Columns @('Id','Title') -Values @('MyId', 'MyTitle') -Table Events -Id "MyId"
$cmd = New-Object System.Data.CData.Cvent.CventCommand("UPDATE Events SET Virtual='true' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Cvent.CventParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-Cvent -Connection $Cvent -Table Events -Columns @("Id", "Title") -Values @("MyId", "MyTitle")
$cmd = New-Object System.Data.CData.Cvent.CventCommand("INSERT INTO Events (Virtual) VALUES (@myVirtual)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Cvent.CventParameter("@myVirtual","true")))
$cmd.ExecuteNonQuery()
Remove-Cvent -Connection $Cvent -Table "Events" -Id "MyId"
$cmd = New-Object System.Data.CData.Cvent.CventCommand("DELETE FROM Events WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.Cvent.CventParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Cvent Data Provider to get started:
Download NowLearn more:
👁 Cvent IconRapidly create and deploy powerful .NET applications that integrate with Cvent.