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:

  1. Sign into Cvent and navigate to App Switcher (the blue button in the upper right corner of the page) >> Admin.
  2. In the Admin menu, navigate to Integrations >> REST API.
  3. A new tab launches for Developer Management. Click on Manage API Access in the new tab.
  4. 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:readevent/attendees:writeevent/contacts:read
      event/contacts:writeevent/custom-fields:readevent/custom-fields:write
      event/events:readevent/events:writeevent/sessions:delete
      event/sessions:readevent/sessions:writeevent/speakers:delete
      event/speakers:readevent/speakers:writebudget/budget-items:read
      budget/budget-items:writeexhibitor/exhibitors:readexhibitor/exhibitors:write
      survey/surveys:readsurvey/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

  1. Install the module:

    Install-Module CventCmdlets
  2. Connect:

    $cvent = Connect-Cvent -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
  3. 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

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Cvent.CventConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. 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()

Ready to get started?

Download a free trial of the Cvent Data Provider to get started:

 Download Now

Learn more:

Cvent Icon Cvent ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Cvent.