Ready to get started?

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

 Download Now

Learn more:

Dropbox Icon Dropbox ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Dropbox file storage data including Files, Folders, Users, and more!

Automate Dropbox Integration Tasks from PowerShell



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

The CData Cmdlets for Dropbox 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 Dropbox.

PowerShell Cmdlets or ADO.NET Provider?

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

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

Dropbox uses the OAuth authentication standard. To authenticate using OAuth, you can use the embedded credentials or register an app with Dropbox.

See the Getting Started guide in the CData driver documentation for more information.

PowerShell

  1. Install the module:

    Install-Module DropboxCmdlets
  2. Connect:

    $dropbox = Connect-Dropbox
  3. Search for and retrieve data:

    $id = "1" $files = Select-Dropbox -Connection $dropbox -Table "Files" -Where "Id = `'$Id`'" $files

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

    $files = Invoke-Dropbox -Connection $dropbox -Query 'SELECT * FROM Files WHERE Id = @Id' -Params @{'@Id'='1'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Dropbox.DropboxConnection("InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the DropboxDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Name from Files" $da= New-Object System.Data.CData.Dropbox.DropboxDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.name }

Update Dropbox Data

PowerShell

Update-Dropbox -Connection $Dropbox -Columns @('Id','Name') -Values @('MyId', 'MyName') -Table Files -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Dropbox.DropboxCommand("UPDATE Files SET Id='1' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Dropbox.DropboxParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Dropbox Data

PowerShell

Add-Dropbox -Connection $Dropbox -Table Files -Columns @("Id", "Name") -Values @("MyId", "MyName")

ADO.NET

$cmd = New-Object System.Data.CData.Dropbox.DropboxCommand("INSERT INTO Files (Id) VALUES (@myId)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Dropbox.DropboxParameter("@myId","1"))) $cmd.ExecuteNonQuery()

Delete Dropbox Data

PowerShell

Remove-Dropbox -Connection $Dropbox -Table "Files" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Dropbox.DropboxCommand("DELETE FROM Files WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Dropbox.DropboxParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()