Ready to get started?

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

 Download Now

Learn more:

eBay Icon eBay ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with eBay auction data including Items, Bidders, Transactions, and more!

Automate eBay Integration Tasks from PowerShell



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

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

PowerShell Cmdlets or ADO.NET Provider?

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

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

If you will be accessing your own account, you can generate an OAuthAccessToken from your developer account dashboard. You can also allow other users to securely access their own accounts.

Both of these methods require you to create an application key set to obtain values for the following connection properties: AppId, CertId, DevId, and SiteId.

The user consent flow additionally requires the RuName and CallbackURL.

See the "Getting Started" chapter in the help documentation for a guide to using OAuth.

PowerShell

  1. Install the module:

    Install-Module EbayCmdlets
  2. Connect:

    $ebay = Connect-Ebay -AppId "$AppId" -CertId "$CertId" -DevId "$DevId" -SiteId "$SiteId" -RuName "$RuName" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $listingstatus = "active" $itemlisting = Select-Ebay -Connection $ebay -Table "ItemListing" -Where "ListingStatus = `'$ListingStatus`'" $itemlisting

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

    $itemlisting = Invoke-Ebay -Connection $ebay -Query 'SELECT * FROM ItemListing WHERE ListingStatus = @ListingStatus' -Params @{'@ListingStatus'='active'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Ebay.EbayConnection("AppId=MyAppId;CertId=MyCertId;DevId=MyDevId;SiteId=MySiteId;RuName=MyRuName;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the EbayDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Title, HitCount from ItemListing" $da= New-Object System.Data.CData.Ebay.EbayDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.title $_.hitcount }

Update eBay Data

PowerShell

Update-Ebay -Connection $Ebay -Columns @('Title','HitCount') -Values @('MyTitle', 'MyHitCount') -Table ItemListing -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Ebay.EbayCommand("UPDATE ItemListing SET ListingStatus='active' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert eBay Data

PowerShell

Add-Ebay -Connection $Ebay -Table ItemListing -Columns @("Title", "HitCount") -Values @("MyTitle", "MyHitCount")

ADO.NET

$cmd = New-Object System.Data.CData.Ebay.EbayCommand("INSERT INTO ItemListing (ListingStatus) VALUES (@myListingStatus)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myListingStatus","active"))) $cmd.ExecuteNonQuery()

Delete eBay Data

PowerShell

Remove-Ebay -Connection $Ebay -Table "ItemListing" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.Ebay.EbayCommand("DELETE FROM ItemListing WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.Ebay.EbayParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()