Cmdlets for Oracle Service Cloud

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 OracleServiceCloud Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Connecting to OracleServiceCloud

You must set the following to authenticate to Oracle Service Cloud:

  • URL: The Url of the account to connect to.
  • User: The username of the authenticating account.
  • Password: The password of the authenticating account.

Creating a Connection Object

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

$conn = Connect-OracleServiceCloud

Retrieving Data

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

$results = Select-OracleServiceCloud -Connection $conn -Table "Accounts" -Columns @("Id, LookupName") -Where "DisplayOrder='12'"
The Invoke-OracleServiceCloud 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-OracleServiceCloud -Connection $conn -Table Accounts -Where "DisplayOrder = '12'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myAccountsData.csv -NoTypeInformation

You will notice that we piped the results from Select-OracleServiceCloud 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-OracleServiceCloud
PS C:\> $row = Select-OracleServiceCloud -Connection $conn -Table "Accounts" -Columns (Id, LookupName) -Where "DisplayOrder = '12'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Accounts",
  "Columns":  [

  ],
  "Id":  "MyId",
  "LookupName":  "MyLookupName"
} 

Deleting Data

The following line deletes any records that match the criteria:

Select-OracleServiceCloud -Connection $conn -Table Accounts -Where "DisplayOrder = '12'" | Remove-OracleServiceCloud

Modifying Data

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

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

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