Automate Pinterest Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Pinterest ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Pinterest.



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

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

Cmdlets or ADO.NET?

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

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

Pinterest authentication is based on the standard OAuth flow. To authenticate, you must initially create an app via the Pinterest developer platform where you can obtain an OAuthClientId, OAuthClientSecret, and CallbackURL.

Set InitiateOAuth to GETANDREFRESH and set OAuthClientId, OAuthClientSecret, and CallbackURL based on the property values for the app you created.

See the Help documentation for other OAuth authentication flows.

PowerShell

  1. Install the module:

    Install-Module PinterestCmdlets
  2. Connect:

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

    $firstname = "Jane" $users = Select-Pinterest -Connection $pinterest -Table "Users" -Where "FirstName = `'$FirstName`'" $users

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

    $users = Invoke-Pinterest -Connection $pinterest -Query 'SELECT * FROM Users WHERE FirstName = @FirstName' -Params @{'@FirstName'='Jane'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Pinterest.PinterestConnection("OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='https://localhost:33333'InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the PinterestDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Username from Users" $da= New-Object System.Data.CData.Pinterest.PinterestDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.username }