Automate Amazon Marketplace Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Amazon Marketplace data from PowerShell? This article demonstrates how to utilize the Amazon Marketplace Cmdlets for tasks like connecting to Amazon Marketplace data, automating operations, downloading data, 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.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Amazon Marketplace, 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.

Once you have acquired the necessary connection properties, accessing Amazon Marketplace data in PowerShell can be enabled in three 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 }

Ready to get started?

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

 Download Now

Learn more:

Amazon Marketplace Icon Amazon Marketplace ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Amazon Marketplace data including InventoryItems, Orders, Products, and more!