![]() |
VOOZH | about |
The CData Cmdlets for Confluence are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Confluence.
The Cmdlets are not only a PowerShell interface to Confluence, but also an SQL interface; this tutorial shows how to use both to retrieve Confluence data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Confluence. To access Confluence data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Confluence.
Once you have acquired the necessary connection properties, accessing Confluence data in PowerShell can be enabled in three steps.
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.
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.):
To connect to a Server instance, provide the following:
Install the module:
Install-Module ConfluenceCmdlets
Connect:
$confluence = Connect-Confluence -User "$User" -APIToken "$APIToken" -Url "$Url" -Timezone "$Timezone"
Search for and retrieve data:
$id = "10000" $pages = Select-Confluence -Connection $confluence -Table "Pages" -Where "Id = `'$Id`'" $pages
You can also use the Invoke-Confluence cmdlet to execute SQL commands:
$pages = Invoke-Confluence -Connection $confluence -Query 'SELECT * FROM Pages WHERE Id = @Id' -Params @{'@Id'='10000'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Confluence\lib\System.Data.CData.Confluence.dll")
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()
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
}
Download a free trial of the Confluence Data Provider to get started:
Download NowLearn more:
👁 Confluence IconRapidly create and deploy powerful .NET applications that integrate with Confluence.