Cmdlets for Blackbaud Raisers Edge NXT

Build 21.0.7930

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 RaiserEdgeNXT 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 RaiserEdgeNXTCmdlets

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

Import-Module RaiserEdgeNXTCmdlets;

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

$conn = Connect-RaiserEdgeNXT -OAuthClientId "MyOAuthClientId" -OAuthClientSecret "MyOAuthClientSecret" -SubscriptionKey "MySubscriptionKey" -CallbackURL "http://localhost:33333"

Connecting to BlackBaud Raiser's Edge NXT

Before establishing a connection, supply the SubscriptionKey, found in the BlackBaud Raiser's Edge NXT Profile.

Authenticating to BlackBaud Raiser's Edge NXT

BlackBaud Raiser's Edge NXT uses the OAuth authentication standard. You can connect to BlackBaud Raiser's Edge NXT without setting any connection properties using the Embedded Credentials.

Alternatively, you can authenticate by Creating a Custom OAuth App to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties.

See Using OAuth Authentication for an authentication guide.

Retrieving Data

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

$results = Select-RaiserEdgeNXT -Connection $conn -Table "Constituents" -Columns @("Id, AddressLines") -Where "Type='Home'"
The Invoke-RaiserEdgeNXT 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-RaiserEdgeNXT -Connection $conn -Table Constituents -Where "Type = 'Home'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myConstituentsData.csv -NoTypeInformation

You will notice that we piped the results from Select-RaiserEdgeNXT 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-RaiserEdgeNXT -OAuthClientId "MyOAuthClientId" -OAuthClientSecret "MyOAuthClientSecret" -SubscriptionKey "MySubscriptionKey" -CallbackURL "http://localhost:33333"
PS C:\> $row = Select-RaiserEdgeNXT -Connection $conn -Table "Constituents" -Columns (Id, AddressLines) -Where "Type = 'Home'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Constituents",
  "Columns":  [

  ],
  "Id":  "MyId",
  "AddressLines":  "MyAddressLines"
} 

Updating Data

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

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

Copyright (c) 2021 CData Software, Inc. - All rights reserved.
Build 21.0.7930