Automate Vault CRM Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Vault CRM data from PowerShell? This article demonstrates how to utilize the Vault CRM Cmdlets for tasks like connecting to Vault CRM data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Vault CRM is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Vault CRM.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Vault CRM; this tutorial shows how to use the Provider to create, retrieve, update, and delete Vault CRM data.

Once you have acquired the necessary connection properties, accessing Vault CRM data in PowerShell can be enabled in three steps.

You are ready to connect after specifying the following connection properties:

  • Url: The host you see in the URL after you login to your account. For example: https://my-veeva-domain.veevavault.com
  • User: The username you use to login to your account.
  • Password: The password you use to login to your account.
  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.VaultCRM.VaultCRMConnection("User=myuser;Password=mypassword;Server=localhost;Database=mydatabase;")
    $conn.Open()
  3. Instantiate the VaultCRMDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT ProductId, ProductName from NorthwindProducts"
    
    $da= New-Object System.Data.CData.VaultCRM.VaultCRMDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.productid $_.productname
    }

Update Vault CRM Data

$cmd =  New-Object System.Data.CData.VaultCRM.VaultCRMCommand("UPDATE NorthwindProducts SET CategoryId='5' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VaultCRM.VaultCRMParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Vault CRM Data

$cmd =  New-Object System.Data.CData.VaultCRM.VaultCRMCommand("INSERT INTO NorthwindProducts (CategoryId) VALUES (@myCategoryId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VaultCRM.VaultCRMParameter("@myCategoryId","5")))
$cmd.ExecuteNonQuery()

Delete Vault CRM Data

$cmd =  New-Object System.Data.CData.VaultCRM.VaultCRMCommand("DELETE FROM NorthwindProducts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VaultCRM.VaultCRMParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

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

 Download Now

Learn more:

Vault CRM Icon Vault CRM ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Vault CRM data including Documents, Users, Groups, and more!