Cmdlets for Jira Assets

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

Connecting and Authenticating to Jira Assets

Jira Assets supports connecting and authenticating via the APIToken.

To generate an API token:

  1. Log in to your Atlassian account.
  2. Navigate to Security > Create and manage API Token > Create API Token.
Atlassian generates and then displays the API token.

After you have generated the API token, set these parameters:

You are now ready to connect and authenticate to Jira Assets.

Creating a Connection Object

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

$conn = Connect-JiraAssets -User 'MyUser' -APIToken '123abc' -Url 'https://yoursitename.atlassian.net'

Retrieving Data

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

$results = Select-JiraAssets -Connection $conn -Table "Objects" -Columns @("Id, Name") -Where "Column2='Bob'"
The Invoke-JiraAssets 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-JiraAssets -Connection $conn -Table Objects -Where "Column2 = 'Bob'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myObjectsData.csv -NoTypeInformation

You will notice that we piped the results from Select-JiraAssets 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-JiraAssets -User 'MyUser' -APIToken '123abc' -Url 'https://yoursitename.atlassian.net'
PS C:\> $row = Select-JiraAssets -Connection $conn -Table "Objects" -Columns (Id, Name) -Where "Column2 = 'Bob'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Objects",
  "Columns":  [

  ],
  "Id":  "MyId",
  "Name":  "MyName"
} 

Deleting Data

The following line deletes any records that match the criteria:

Select-JiraAssets -Connection $conn -Table Objects -Where "Column2 = 'Bob'" | Remove-JiraAssets

Modifying Data

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

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

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