Ready to get started?

Download a free trial of the IBM Cloud Object Storage Data Provider to get started:

 Download Now

Learn more:

IBM Cloud Object Storage Icon IBM Cloud Object Storage ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with IBM Cloud Object Storage.

Automate IBM Cloud Object Storage Integration Tasks from PowerShell

Are you in search of a quick and easy way to access IBM Cloud Object Storage data from PowerShell? This article demonstrates how to utilize the IBM Cloud Object Storage Cmdlets and the CData ADO.NET Provider for IBM Cloud Object Storage for tasks like connecting to IBM Cloud Object Storage data, automating operations, downloading data, and more.

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.

PowerShell Cmdlets or ADO.NET Driver?

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.

Register a New Instance of Cloud Object Storage

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:

  1. Log in to your IBM Cloud account.
  2. Navigate to the page, choose a name for your instance and click Create. You will be redirected to the instance of Cloud Object Storage you just created.

Connecting using OAuth Authentication

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:

  1. Log in to your IBM Cloud account.
  2. Navigate to the Platform API Keys page.
  3. On the middle-right corner click "Create an IBM Cloud API Key" to create a new API Key.
  4. In the pop-up window, specify the API Key name and click "Create". Note the API Key as you can never access it again from the dashboard.

Cloud Object Storage CRN

If you have multiple accounts, you will need to specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:

  • Query the Services view. This will list your IBM Cloud Object Storage instances along with the CRN for each.
  • Locate the CRN directly in IBM Cloud. To do so, navigate to your IBM Cloud Dashboard. In the Resource List, Under Storage, select your Cloud Object Storage resource to get its CRN.

Connecting to Data

You can now set the following to connect to data:

  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  • ApiKey: Set this to your API key which was noted during setup.
  • CloudObjectStorageCRN (Optional): Set this to the cloud object storage CRN you want to work with. While the connector attempts to retrieve this automatically, specifying this explicitly is recommended if you have more than Cloud Object Storage account.

When you connect, the connector completes the OAuth process.

  1. Extracts the access token and authenticates requests.
  2. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.


  1. Install the module:

    Install-Module IBMCloudObjectStorageCmdlets
  2. Connect:

    $ibmcloudobjectstorage = Connect-IBMCloudObjectStorage -ApiKey "$ApiKey" -CloudObjectStorageCRN "$CloudObjectStorageCRN" -Region "$Region" -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
  3. 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'}


  1. 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")
  2. 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()
  3. 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 }