We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →Automate DocuSign Integration Tasks from PowerShell
Are you in search of a quick and easy way to access DocuSign data from PowerShell? This article demonstrates how to utilize the DocuSign Cmdlets for tasks like connecting to DocuSign data, automating operations, downloading data, 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.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to DocuSign, 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.
Once you have acquired the necessary connection properties, accessing DocuSign data in PowerShell can be enabled in three 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
-
Install the module:
Install-Module DocuSignCmdlets
-
Connect:
$docusign = Connect-DocuSign -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
-
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
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for DocuSign\lib\System.Data.CData.DocuSign.dll")
-
Connect to DocuSign:
$conn= New-Object System.Data.CData.DocuSign.DocuSignConnection("OAuthClientId=MyClientId; OAuthClientSecret=MyClientSecret; CallbackURL=http://localhost:33333; InitiateOAuth=GETANDREFRESH") $conn.Open()
-
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 }