Ready to get started?

Learn more about the CData ADO.NET Provider for DocuSign or download a free trial:

Download Now

Automate DocuSign Integration Tasks from PowerShell

Are you looking for a quick and easy way to access DocuSign data from PowerShell? We show how to use the Cmdlets for DocuSign and the CData ADO.NET Provider for DocuSign to connect to DocuSign data and synchronize, automate, download, and more.

The CData Cmdlets for DocuSign are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to DocuSign.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the DocuSign API, but also an SQL interface; this tutorial shows how to use both to retrieve DocuSign data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for DocuSign. To access DocuSign data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for DocuSign.

After obtaining the needed connection properties, accessing DocuSign data in PowerShell consists of three basic steps.

To connect to DocuSign, set the following connection properties:

  • UseSandbox: indicates whether current user account is sandbox or not (FALSE by default)
  • AccountId (optional): set it in the connection string if you have access to multiple Account Ids

Authenticating to DocuSign

DocuSign uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the Help documentation more information.

PowerShell

  1. Install the module:

    Install-Module DocuSignCmdlets
  2. Connect:

    $docusign = Connect-DocuSign -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $documentname = "TPSReport" $documents = Select-DocuSign -Connection $docusign -Table "Documents" -Where "DocumentName = `'$DocumentName`'" $documents

    You can also use the Invoke-DocuSign cmdlet to execute SQL commands:

    $documents = Invoke-DocuSign -Connection $docusign -Query 'SELECT * FROM Documents WHERE DocumentName = @DocumentName' -Params @{'@DocumentName'='TPSReport'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.DocuSign.DocuSignConnection("OAuthClientId=MyClientId; OAuthClientSecret=MyClientSecret; CallbackURL=http://localhost:33333; InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the DocuSignDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT DocumentId, DocumentName from Documents" $da= New-Object System.Data.CData.DocuSign.DocuSignDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.documentid $_.documentname }