Automate Confluence Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access Confluence data from PowerShell? This article demonstrates how to utilize the Confluence Cmdlets for tasks like connecting to Confluence data, automating operations, downloading data, and more.

The CData ADO.NET Provider for Confluence is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Confluence.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Confluence; this tutorial shows how to use the Provider to retrieve Confluence data.

Once you have acquired the necessary connection properties, accessing Confluence data in PowerShell can be enabled in three steps.

Obtaining an API Token

An API token is necessary for account authentication. To generate one, login to your Atlassian account and navigate to API tokens > Create API token. The generated token will be displayed.

Connect Using a Confluence Cloud Account

To connect to a Cloud account, provide the following (Note: Password has been deprecated for connecting to a Cloud Account and is now used only to connect to a Server Instance.):

  • User: The user which will be used to authenticate with the Confluence server.
  • APIToken: The API Token associated with the currently authenticated user.
  • Url: The URL associated with your JIRA endpoint. For example, https://yoursitename.atlassian.net.

Connect Using a Confluence Server Instance

To connect to a Server instance, provide the following:

  • User: The user which will be used to authenticate with the Confluence instance.
  • Password: The password which will be used to authenticate with the Confluence server.
  • Url: The URL associated with your JIRA endpoint. For example, https://yoursitename.atlassian.net.
  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Confluence\lib\System.Data.CData.Confluence.dll")
        
  2. Connect to Confluence:

     
    $conn= New-Object System.Data.CData.Confluence.ConfluenceConnection("User=admin;APIToken=myApiToken;Url=https://yoursitename.atlassian.net;Timezone=America/New_York;")
    $conn.Open()
    
  3. Instantiate the ConfluenceDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT Key, Name from Pages"
    
    $da= New-Object System.Data.CData.Confluence.ConfluenceDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.key $_.name
    }
      

Ready to get started?

Download a free trial of the Confluence Data Provider to get started:

 Download Now

Learn more:

Confluence Icon Confluence ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Confluence data including Attachments, Comments, Groups, Users, and more!