Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Automate Cvent Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Cvent data from PowerShell? This article demonstrates how to utilize the Cvent Cmdlets for tasks like connecting to Cvent data, automating operations, downloading data, and more.
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.
PowerShell Cmdlets or ADO.NET Provider?
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.
Creating a Workspace
To create a workspace:
- Sign into Cvent and navigate to App Switcher (the blue button in the upper right corner of the page) >> Admin.
- In the Admin menu, navigate to Integrations >> REST API.
- A new tab launches for Developer Management. Click on Manage API Access in the new tab.
- Create a Workspace and name it. Select the scopes you would like your developers to have access to. Scopes control what data domains the developer can access.
- Choose All to allow developers to choose any scope, and any future scopes added to the REST API.
- Choose Custom to limit the scopes developers can choose for their OAuth apps to selected scopes. To access all tables exposed by the driver, you need to set the following scopes:
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
Creating an OAuth Application
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.
Connecting to Cvent
After creating an OAuth application, set the following connection properties to connect to Cvent:
- InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
- OAuthClientId: The Client ID associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.
- OAuthClientSecret: The Client secret associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.
PowerShell
-
Install the module:
Install-Module CventCmdlets
-
Connect:
$cvent = Connect-Cvent -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
-
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'}
ADO.NET
-
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 Data
PowerShell
Update-Cvent -Connection $Cvent -Columns @('Id','Title') -Values @('MyId', 'MyTitle') -Table Events -Id "MyId"
ADO.NET
$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()
Insert Cvent Data
PowerShell
Add-Cvent -Connection $Cvent -Table Events -Columns @("Id", "Title") -Values @("MyId", "MyTitle")
ADO.NET
$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()
Delete Cvent Data
PowerShell
Remove-Cvent -Connection $Cvent -Table "Events" -Id "MyId"
ADO.NET
$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