![]() |
VOOZH | about |
The CData Cmdlets for IBM Cloud Object Storage are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to IBM Cloud Object Storage.
The Cmdlets are not only a PowerShell interface to IBM Cloud Object Storage, but also an SQL interface; this tutorial shows how to use both to retrieve IBM Cloud Object Storage data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for IBM Cloud Object Storage. To access IBM Cloud Object Storage data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for IBM Cloud Object Storage.
Once you have acquired the necessary connection properties, accessing IBM Cloud Object Storage data in PowerShell can be enabled in three steps.
If you do not already have Cloud Object Storage in your IBM Cloud account, follow the procedure below to install an instance of SQL Query in your account:
There are certain connection properties you need to set before you can connect. You can obtain these as follows:
To connect with IBM Cloud Object Storage, you need an API Key. You can obtain this as follows:
If you have multiple accounts, specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:
You can now set the following to connect to data:
When you connect, the connector completes the OAuth process.
Install the module:
Install-Module IBMCloudObjectStorageCmdlets
Connect:
$ibmcloudobjectstorage = Connect-IBMCloudObjectStorage -ApiKey "$ApiKey" -CloudObjectStorageCRN "$CloudObjectStorageCRN" -Region "$Region" -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
Search for and retrieve data:
$bucket = "someBucket" $objects = Select-IBMCloudObjectStorage -Connection $ibmcloudobjectstorage -Table "Objects" -Where "Bucket = `'$Bucket`'" $objects
You can also use the Invoke-IBMCloudObjectStorage cmdlet to execute SQL commands:
$objects = Invoke-IBMCloudObjectStorage -Connection $ibmcloudobjectstorage -Query 'SELECT * FROM Objects WHERE Bucket = @Bucket' -Params @{'@Bucket'='someBucket'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for IBM Cloud Object Storage\lib\System.Data.CData.IBMCloudObjectStorage.dll")
Connect to IBM Cloud Object Storage:
$conn= New-Object System.Data.CData.IBMCloudObjectStorage.IBMCloudObjectStorageConnection("ApiKey=myApiKey;CloudObjectStorageCRN=MyInstanceCRN;Region=myRegion;OAuthClientId=MyOAuthClientId;OAuthClientSecret=myOAuthClientSecret;")
$conn.Open()
Instantiate the IBMCloudObjectStorageDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Key, Etag from Objects"
$da= New-Object System.Data.CData.IBMCloudObjectStorage.IBMCloudObjectStorageDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.key $_.etag
}
Download a free trial of the IBM Cloud Object Storage Data Provider to get started:
Download NowLearn more:
👁 IBM Cloud Object Storage IconRapidly create and deploy powerful .NET applications that integrate with IBM Cloud Object Storage.