Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Automate Oracle Service Cloud Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Oracle Service Cloud data from PowerShell? This article demonstrates how to utilize the Oracle Service Cloud Cmdlets for tasks like connecting to Oracle Service Cloud data, automating operations, downloading data, and more.
The CData Cmdlets for Oracle Service Cloud 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 Oracle Service Cloud.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Oracle Service Cloud, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Oracle Service Cloud data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Oracle Service Cloud. To access Oracle Service Cloud data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Oracle Service Cloud.
Once you have acquired the necessary connection properties, accessing Oracle Service Cloud data in PowerShell can be enabled in three steps.
Using Basic Authentication
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.
PowerShell
-
Install the module:
Install-Module OracleServiceCloudCmdlets
-
Connect:
$oracleservicecloud = Connect-OracleServiceCloud -Url "$Url" -User "$User" -Password "$Password"
-
Search for and retrieve data:
$displayorder = "12" $accounts = Select-OracleServiceCloud -Connection $oracleservicecloud -Table "Accounts" -Where "DisplayOrder = `'$DisplayOrder`'" $accounts
You can also use the Invoke-OracleServiceCloud cmdlet to execute SQL commands:
$accounts = Invoke-OracleServiceCloud -Connection $oracleservicecloud -Query 'SELECT * FROM Accounts WHERE DisplayOrder = @DisplayOrder' -Params @{'@DisplayOrder'='12'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Oracle Service Cloud\lib\System.Data.CData.OracleServiceCloud.dll")
-
Connect to Oracle Service Cloud:
$conn= New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudConnection("Url=https://abc.rightnowdemo.com;User=user;Password=password;") $conn.Open()
-
Instantiate the OracleServiceCloudDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, LookupName from Accounts" $da= New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.lookupname }
Update Oracle Service Cloud Data
PowerShell
Update-OracleServiceCloud -Connection $OracleServiceCloud -Columns @('Id','LookupName') -Values @('MyId', 'MyLookupName') -Table Accounts -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("UPDATE Accounts SET DisplayOrder='12' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Insert Oracle Service Cloud Data
PowerShell
Add-OracleServiceCloud -Connection $OracleServiceCloud -Table Accounts -Columns @("Id", "LookupName") -Values @("MyId", "MyLookupName")
ADO.NET
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("INSERT INTO Accounts (DisplayOrder) VALUES (@myDisplayOrder)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myDisplayOrder","12")))
$cmd.ExecuteNonQuery()
Delete Oracle Service Cloud Data
PowerShell
Remove-OracleServiceCloud -Connection $OracleServiceCloud -Table "Accounts" -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudCommand("DELETE FROM Accounts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.OracleServiceCloud.OracleServiceCloudParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject