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 Veeva Vault Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Veeva Vault data from PowerShell? This article demonstrates how to utilize the Veeva Vault Cmdlets for tasks like connecting to Veeva Vault data, automating operations, downloading data, and more.
The CData Cmdlets for Veeva Vault 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 Veeva Vault.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Veeva Vault, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Veeva Vault data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Veeva. To access Veeva Vault data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Veeva.
Once you have acquired the necessary connection properties, accessing Veeva Vault 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.
PowerShell
-
Install the module:
Install-Module VeevaVaultCmdlets
-
Connect:
$veevavault = Connect-Veeva -User "$User" -Password "$Password" -Server "$Server" -Database "$Database"
-
Search for and retrieve data:
$categoryid = "5" $northwindproducts = Select-Veeva -Connection $veevavault -Table "NorthwindProducts" -Where "CategoryId = `'$CategoryId`'" $northwindproducts
You can also use the Invoke-Veeva cmdlet to execute SQL commands:
$northwindproducts = Invoke-Veeva -Connection $veevavault -Query 'SELECT * FROM NorthwindProducts WHERE CategoryId = @CategoryId' -Params @{'@CategoryId'='5'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Veeva\lib\System.Data.CData.VeevaVault.dll")
-
Connect to Veeva Vault:
$conn= New-Object System.Data.CData.VeevaVault.VeevaVaultConnection("User=myuser;Password=mypassword;Server=localhost;Database=mydatabase;") $conn.Open()
-
Instantiate the VeevaVaultDataAdapter, execute an SQL query, and output the results:
$sql="SELECT ProductId, ProductName from NorthwindProducts" $da= New-Object System.Data.CData.VeevaVault.VeevaVaultDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.productid $_.productname }
Update Veeva Vault Data
PowerShell
Update-Veeva -Connection $VeevaVault -Columns @('ProductId','ProductName') -Values @('MyProductId', 'MyProductName') -Table NorthwindProducts -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.VeevaVault.VeevaVaultCommand("UPDATE NorthwindProducts SET CategoryId='5' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VeevaVault.VeevaVaultParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Insert Veeva Vault Data
PowerShell
Add-Veeva -Connection $VeevaVault -Table NorthwindProducts -Columns @("ProductId", "ProductName") -Values @("MyProductId", "MyProductName")
ADO.NET
$cmd = New-Object System.Data.CData.VeevaVault.VeevaVaultCommand("INSERT INTO NorthwindProducts (CategoryId) VALUES (@myCategoryId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VeevaVault.VeevaVaultParameter("@myCategoryId","5")))
$cmd.ExecuteNonQuery()
Delete Veeva Vault Data
PowerShell
Remove-Veeva -Connection $VeevaVault -Table "NorthwindProducts" -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.VeevaVault.VeevaVaultCommand("DELETE FROM NorthwindProducts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.VeevaVault.VeevaVaultParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject