Automate AWS Management Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

AWS Management ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with live AWS Management data!



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

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

Cmdlets or ADO.NET?

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

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

To authorize AWSDataManagement requests, provide the credentials for an administrator account or for an IAM user with custom permissions:

  1. Set AccessKey to the access key Id.
  2. Set SecretKey to the secret access key.
  3. Set Region to the region where your AWSDataManagement data is hosted.

Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.

PowerShell

  1. Install the module:

    Install-Module AWSDataManagementCmdlets
  2. Connect:

    $awsdatamanagement = Connect-AWSDataManagement -AccessKey "$AccessKey" -Account "$Account" -Region "$Region"
  3. Search for and retrieve data:

    $id = "1" $northwingproducts = Select-AWSDataManagement -Connection $awsdatamanagement -Table "NorthwingProducts" -Where "Id = `'$Id`'" $northwingproducts

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

    $northwingproducts = Invoke-AWSDataManagement -Connection $awsdatamanagement -Query 'SELECT * FROM NorthwingProducts WHERE Id = @Id' -Params @{'@Id'='1'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.AWSDataManagement.AWSDataManagementConnection("AccessKey=myAccessKey;Account=myAccountName;Region=us-east-1;") $conn.Open()
  3. Instantiate the AWSDataManagementDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT PartitionKey, Name from NorthwingProducts" $da= New-Object System.Data.CData.AWSDataManagement.AWSDataManagementDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.partitionkey $_.name }

Update AWS Management Data

PowerShell

Update-AWSDataManagement -Connection $AWSDataManagement -Columns @('PartitionKey','Name') -Values @('MyPartitionKey', 'MyName') -Table NorthwingProducts -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.AWSDataManagement.AWSDataManagementCommand("UPDATE NorthwingProducts SET Id='1' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.AWSDataManagement.AWSDataManagementParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert AWS Management Data

PowerShell

Add-AWSDataManagement -Connection $AWSDataManagement -Table NorthwingProducts -Columns @("PartitionKey", "Name") -Values @("MyPartitionKey", "MyName")

ADO.NET

$cmd = New-Object System.Data.CData.AWSDataManagement.AWSDataManagementCommand("INSERT INTO NorthwingProducts (Id) VALUES (@myId)", $conn) $cmd.Parameters.Add(new System.Data.CData.AWSDataManagement.AWSDataManagementParameter("@myId","1")) $cmd.ExecuteNonQuery()

Delete AWS Management Data

PowerShell

Remove-AWSDataManagement -Connection $AWSDataManagement -Table "NorthwingProducts" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.AWSDataManagement.AWSDataManagementCommand("DELETE FROM NorthwingProducts WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.AWSDataManagement.AWSDataManagementParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()