Ready to get started?

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

 Download Now

Learn more:

Shopify Icon Shopify ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Shopify Ecommerce Software.

Automate Shopify Integration Tasks from PowerShell



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

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

PowerShell Cmdlets or ADO.NET Provider?

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

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

To make use of all the features of the data provider, provide the AppId, Password, and ShopUrl connection properties.

To obtain these values, see the Getting Started section in the help documentation to register the data provider as an application with Shopify.

PowerShell

  1. Install the module:

    Install-Module ShopifyCmdlets
  2. Connect:

    $shopify = Connect-Shopify -AppId "$AppId" -Password "$Password" -ShopUrl "$ShopUrl"
  3. Search for and retrieve data:

    $firstname = "jdoe1234" $customers = Select-Shopify -Connection $shopify -Table "Customers" -Where "FirstName = `'$FirstName`'" $customers

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

    $customers = Invoke-Shopify -Connection $shopify -Query 'SELECT * FROM Customers WHERE FirstName = @FirstName' -Params @{'@FirstName'='jdoe1234'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Shopify.ShopifyConnection("AppId=MyAppId;Password=MyPassword;ShopUrl=https://yourshopname.myshopify.com;") $conn.Open()
  3. Instantiate the ShopifyDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT FirstName, Id from Customers" $da= New-Object System.Data.CData.Shopify.ShopifyDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.firstname $_.id }

Update Shopify Data

PowerShell

Update-Shopify -Connection $Shopify -Columns @('FirstName','Id') -Values @('MyFirstName', 'MyId') -Table Customers -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Shopify.ShopifyCommand("UPDATE Customers SET FirstName='jdoe1234' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Shopify.ShopifyParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Shopify Data

PowerShell

Add-Shopify -Connection $Shopify -Table Customers -Columns @("FirstName", "Id") -Values @("MyFirstName", "MyId")

ADO.NET

$cmd = New-Object System.Data.CData.Shopify.ShopifyCommand("INSERT INTO Customers (FirstName) VALUES (@myFirstName)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Shopify.ShopifyParameter("@myFirstName","jdoe1234"))) $cmd.ExecuteNonQuery()

Delete Shopify Data

PowerShell

Remove-Shopify -Connection $Shopify -Table "Customers" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Shopify.ShopifyCommand("DELETE FROM Customers WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Shopify.ShopifyParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()