Ready to get started?

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

Download Now

Automate Amazon Marketplace Integration Tasks from PowerShell

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

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

Cmdlets or ADO.NET?

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

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

To connect to the Amazon Marketplace Webservice (MWS), AWSAccessKeyId, MWSAuthToken, AWSSecretKey and SellerId are required. You can optionally set the Marketplace property. For more information on obtaining values for these properties, refer to the Help documentation.

PowerShell

  1. Install the module:

    Install-Module AmazonMarketplaceCmdlets
  2. Connect:

    $amazonmarketplace = Connect-AmazonMarketplace -AWS Access Key Id "$AWS Access Key Id" -AWS Secret Key "$AWS Secret Key" -MWS Auth Token "$MWS Auth Token" -Seller Id "$Seller Id" -Marketplace "$Marketplace"
  3. Search for and retrieve data:

    $isreplacementorder = "True" $orders = Select-AmazonMarketplace -Connection $amazonmarketplace -Table "Orders" -Where "IsReplacementOrder = `'$IsReplacementOrder`'" $orders

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

    $orders = Invoke-AmazonMarketplace -Connection $amazonmarketplace -Query 'SELECT * FROM Orders WHERE IsReplacementOrder = @IsReplacementOrder' -Params @{'@IsReplacementOrder'='True'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.AmazonMarketplace.AmazonMarketplaceConnection("AWS Access Key Id=myAWSAccessKeyId;AWS Secret Key=myAWSSecretKey;MWS Auth Token=myMWSAuthToken;Seller Id=mySellerId;Marketplace=United States;") $conn.Open()
  3. Instantiate the AmazonMarketplaceDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT AmazonOrderId, OrderStatus from Orders" $da= New-Object System.Data.CData.AmazonMarketplace.AmazonMarketplaceDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.amazonorderid $_.orderstatus }