Cmdlets for SAP BusinessObjects BI

Build 24.0.8963

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

Installing and Connecting

If you have PSGet, installing the cmdlets can be accomplished from the PowerShell Gallery with the following command. You can also obtain a setup from the CData site.

Install-Module SAPBusinessObjectsBICmdlets

The following line is then added to your profile, loading the cmdlets on the next session:

Import-Module SAPBusinessObjectsBICmdlets;

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

$conn = Connect-SAPBusinessObjectsBI -User "MyUser" -Password "MyPassword" -Url "http://myserver:6405/biprws"

Connecting to SAPBusinessObjectsBI

To connect to your SAP BusinessObjects BI instance, you must set the following:

  • Url: The SAP BusinessObjects BI REST API URL. To discover this:

    1. Log into the Central Management Console.
    2. Choose Applications from the combo box.
    3. Select RESTful Web Service. The Central Management Console displays the access URL, which is http://{Server-Name}:6405/biprws by default.

  • AuthScheme: Set this to the type of authentication to use when connecting to SAP BusinessObjects BI.

Basic

To connect to SAP BusinessObjects BI using Basic authentication, set the AuthScheme to Basic, and set these properties:

  • User: The username of your instance.
  • Password: The password of your instance.

CyberArk

To connect to CyberArk, set the AuthScheme to CyberArk, and set these properties:

  • User: The CyberArk login name (user@domain).
  • Password: The CyberArk user's password.
  • SSOLoginURL: The app's single sign on URL.
  • SSOExchangeUrl: The url used for the exchange of the SAML token for SAP BusinessObjects BI credentials.

If you have configured MFA, you must use combinations of SSOProperties to authenticate using CyberArk. Set any of the following, as applicable:

  • MFAType: If you have configured MFA, set this to the name of the mechanism that should be selected during authentication.
  • MFAPassCode: If you have configured MFA, set this to a valid answer for the selected mechanism.
    If you set this to an empty or an invalid value, the cmdlet initiates the out-of-band mechanism. The cmdlet polls the API until the challenge is completed through user interaction before deciding on closing the connection.
  • MFATimeout: If you have configured MFA, set this to the number of seconds the cmdlet should continue polling the API until the challenge is completed through user interaction. By default, the cmdlet polls the API for 60 seconds before closing the connection.

Example connection string:

AuthScheme=CyberArk;SSOLoginURL='https://abc1234.id.cyberark.cloud/run?appkey=00000000-0000-0000-0000-000000000000&customerId=ABC1234';User=cyberarkUserName;Password=cyberarkPassword;SSOExchangeUrl=http://myserver:8080/biprws/saml/SSO;

Retrieving Data

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

$results = Select-SAPBusinessObjectsBI -Connection $conn -Table "MyCustomReport" -Columns @("StoreName, Column1") -Where "Column2='Bob'"
The Invoke-SAPBusinessObjectsBI 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-SAPBusinessObjectsBI -Connection $conn -Table MyCustomReport -Where "Column2 = 'Bob'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myMyCustomReportData.csv -NoTypeInformation

You will notice that we piped the results from Select-SAPBusinessObjectsBI 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-SAPBusinessObjectsBI -User "MyUser" -Password "MyPassword" -Url "http://myserver:6405/biprws"
PS C:\> $row = Select-SAPBusinessObjectsBI -Connection $conn -Table "MyCustomReport" -Columns (StoreName, Column1) -Where "Column2 = 'Bob'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "MyCustomReport",
  "Columns":  [

  ],
  "StoreName":  "MyStoreName",
  "Column1":  "MyColumn1"
} 

Modifying Data

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

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

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.8963