Cmdlets for Veeva Vault

Build 20.0.7654

Establishing a Connection

With the CData Cmdlets users can install a data module, set the connection properties, and start scripting. This section provides examples of using our VeevaVault Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Installing and Connecting

If you have PSGet, installing the cmdlets can be accomplished from the PowerShell Gallery with the following command. You can also obtain a setup from the CData site.

Install-Module VeevaVaultCmdlets

The following line is then added to your profile, loading the cmdlets on the next session:

Import-Module VeevaVaultCmdlets;

You can then use the Connect-VeevaVault cmdlet to create a connection object that can be passed to other cmdlets:

$conn = Connect-VeevaVault -Url "myURL" -User "myUser" -Password "myPassword"

Connecting to Veeva Vault

The provider supports only basic authentication. 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.
  • User: The username you use to login to your account.
  • Password: The password you use to login to your account.

Retrieving Data

The Select-VeevaVault cmdlet provides a native PowerShell interface for retrieving data:

$results = Select-VeevaVault -Connection $conn -Table "Documents" -Columns @("Id, Name") -Where "Name='Test'"
The Invoke-VeevaVault cmdlet provides an SQL interface. This cmdlet can be used to execute an SQL query via the Query parameter.

Piping Cmdlet Output

The cmdlets return row objects to the pipeline one row at a time. The following line exports results to a CSV file:

Select-VeevaVault -Connection $conn -Table Documents -Where "Name = 'Test'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myDocumentsData.csv -NoTypeInformation

You will notice that we piped the results from Select-VeevaVault into a Select-Object cmdlet and excluded some properties before piping them into an Export-CSV cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each row object in the result set, and we do not necessarily want that information in our CSV file.

However, this makes it easy to pipe the output of one cmdlet to another. The following is an example of converting a result set to JSON:

PS C:\> $conn  = Connect-VeevaVault -Url "myURL" -User "myUser" -Password "myPassword"
PS C:\> $row = Select-VeevaVault -Connection $conn -Table "Documents" -Columns (Id, Name) -Where "Name = 'Test'" | select -first 1
PS C:\> $row | ConvertTo-Json
  "Connection":  {

  "Table":  "Documents",
  "Columns":  [

  "Id":  "MyId",
  "Name":  "MyName"

Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 20.0.7654