How to authenticate to confluence with PAT using PowerShell?

Dennis A_ April 4, 2022

Is there a way to authenticate to Confluence using a Personal Access Token with PowerShell? I don't see a method using the ConfluencePS module.  My connection script uses that PowerShell module via the Set-ConfluenceInfo method, but there does not seem to be a way to use the PAT with it.

2 answers

1 accepted

0 votes
Answer accepted
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 4, 2022

Hi @Dennis A_ 

Welcome to the Atlassian Community.

ConfluencePS is maintained by a community unrelated to Atlassian. More information can be found in https://atlassianps.org/docs/Contributing/ .

Checking their documentation I don't see something specific to authenticate with PAT on Confluence Server/DC.

However, on the server configuration there seems to be a possibility to include http headers on every request, on which you might be able to configure your user's PAT.

See https://atlassianps.org/docs/AtlassianPS.Configuration/commands/Add-ServerConfiguration/ for more information on that configuration.

I hope that helps.

Kind regards

Thiago Masutti

Dennis A_ April 7, 2022

I found a fork that accepts PAT (https://github.com/jamiekowalczik/ConfluencePS). 

0 votes
tristian o_brien
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2024

not sure if this will help, but i connected using a token like this.

Import-Module ConfluencePS

$Username = '************@gmail.com'

#generate a key from here https://id.atlassian.com/manage-profile/security/api-tokens

$Key = '******************************************' `

    | ConvertTo-SecureString -AsPlainText -Force

$Credentials = New-Object System.Management.Automation.PsCredential($Username,$Key)

#Set-ConfluenceInfo -BaseURI 'https://********.atlassian.net/wiki' -Credential $Credentials

Get-ConfluenceSpace

#https://***********.atlassian.net/wiki/spaces/~712020e628e2b3818645efb1b64e5371f102bc/pages/294914/page+1

 

Get-ConfluencePage -PageID 294914 | Format-List * #get page info including content

#get space ley from it's url

$pages = Get-ConfluencePage -SpaceKey "~712020e628e2b3818645efb1b64e5371f102bc"

$pages | ForEach-Object { $_.Body } #gets page content as HTML

 

Gist https://gist.github.com/tristian2/c33692cbe46e287dd4f9bd5bb887ddb5




Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events