Cmdlets for Oracle Sales

Build 25.0.9434

Establishing a Connection

With the CData Cmdlets users can install a data module, set the connection properties, and start scripting. This section provides examples of using our OracleSalesCloud Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Oracle Sales uses Basic authentication over SSL; after setting the following connection properties, you are ready to connect:

  • Username: Set this to the user name that you use to log into your Oracle Cloud service.
  • Password: Set this to your password.
  • HostURL: Set this to the Web address (URL) of your Oracle Cloud service.

Creating a Connection Object

You can then use the Connect-OracleSalesCloud cmdlet to create a connection object that can be passed to other cmdlets:

$conn = Connect-OracleSalesCloud -HostURL 'https://my.host.oraclecloud.com' -Username 'abc123' -Password 'abcdef'

Retrieving Data

The Select-OracleSalesCloud cmdlet provides a native PowerShell interface for retrieving data:

$results = Select-OracleSalesCloud -Connection $conn -Table "Opportunities" -Columns @("OptyId, Name") -Where "CreatedBy='Jack'"
The Invoke-OracleSalesCloud cmdlet provides an SQL interface. This cmdlet can be used to execute an SQL query via the Query parameter.

Piping Cmdlet Output

The cmdlets return row objects to the pipeline one row at a time. The following line exports results to a CSV file:

Select-OracleSalesCloud -Connection $conn -Table Opportunities -Where "CreatedBy = 'Jack'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myOpportunitiesData.csv -NoTypeInformation

You will notice that we piped the results from Select-OracleSalesCloud into a Select-Object cmdlet and excluded some properties before piping them into an Export-CSV cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each row object in the result set, and we do not necessarily want that information in our CSV file.

However, this makes it easy to pipe the output of one cmdlet to another. The following is an example of converting a result set to JSON:

 
PS C:\> $conn  = Connect-OracleSalesCloud -HostURL 'https://my.host.oraclecloud.com' -Username 'abc123' -Password 'abcdef'
PS C:\> $row = Select-OracleSalesCloud -Connection $conn -Table "Opportunities" -Columns (OptyId, Name) -Where "CreatedBy = 'Jack'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Opportunities",
  "Columns":  [

  ],
  "OptyId":  "MyOptyId",
  "Name":  "MyName"
} 

Deleting Data

The following line deletes any records that match the criteria:

Select-OracleSalesCloud -Connection $conn -Table Opportunities -Where "CreatedBy = 'Jack'" | Remove-OracleSalesCloud

Modifying Data

The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into Oracle Sales, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyOpportunitiesUpdates.csv | %{
  $record = Select-OracleSalesCloud -Connection $conn -Table Opportunities -Where ("Id = `'"+$_.Id+"`'")
  if($record){
    Update-OracleSalesCloud -Connection $conn -Table Opportunities -Columns @("OptyId","Name") -Values @($_.OptyId, $_.Name) -Where "Id  = `'$_.Id`'"
  }else{
    Add-OracleSalesCloud -Connection $conn -Table Opportunities -Columns @("OptyId","Name") -Values @($_.OptyId, $_.Name)
  }
}

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434