Ready to get started?

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

Download Now

Automate Evernote Integration Tasks from PowerShell

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

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

Cmdlets or ADO.NET?

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

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

Evernote uses the OAuth authentication standard. You can use the embedded OAuth application to connect without setting any connection properties. Alternatively, you can create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" chapter of the help documentation for a guide to using OAuth.

PowerShell

  1. Install the module:

    Install-Module EvernoteCmdlets
  2. Connect:

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

    $guid = "ab26f704-5edf-4a9f-9e4c-8da893a4acd8" $notes = Select-Evernote -Connection $evernote -Table "Notes" -Where "Guid = `'$Guid`'" $notes

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

    $notes = Invoke-Evernote -Connection $evernote -Query 'SELECT * FROM Notes WHERE Guid = @Guid' -Params @{'@Guid'='ab26f704-5edf-4a9f-9e4c-8da893a4acd8'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Evernote.EvernoteConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the EvernoteDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Title, Author from Notes" $da= New-Object System.Data.CData.Evernote.EvernoteDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.title $_.author }

Update Evernote Data

PowerShell

Update-Evernote -Connection $Evernote -Columns @('Title','Author') -Values @('MyTitle', 'MyAuthor') -Table Notes -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Evernote.EvernoteCommand("UPDATE Notes SET Guid='ab26f704-5edf-4a9f-9e4c-8da893a4acd8' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Evernote.EvernoteParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Evernote Data

PowerShell

Add-Evernote -Connection $Evernote -Table Notes -Columns @("Title", "Author") -Values @("MyTitle", "MyAuthor")

ADO.NET

$cmd = New-Object System.Data.CData.Evernote.EvernoteCommand("INSERT INTO Notes (Guid) VALUES (@myGuid)", $conn) $cmd.Parameters.Add(new System.Data.CData.Evernote.EvernoteParameter("@myGuid","ab26f704-5edf-4a9f-9e4c-8da893a4acd8")) $cmd.ExecuteNonQuery()

Delete Evernote Data

PowerShell

Remove-Evernote -Connection $Evernote -Table "Notes" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Evernote.EvernoteCommand("DELETE FROM Notes WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.Evernote.EvernoteParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()