Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Download File from Bitbucket repository using powershell

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!
February 27, 2024

Hi all,

I am new to Bitbucket and am trying to use PowerShell to download a file from the Bitbucket repository. The downloaded file is throwing the below error. Can someone help me with the same.

Below is the code.



Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force

# Define your Bitbucket credentials
$username = "username"
$password = "password"

# Convert credentials to Base64
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

# Define the Bitbucket URL of the file you want to download
$bitbucketUrl = "gitbucket link to the file"

# Define the local path where you want to save the downloaded file
$localPath = "C:\Temp\Download\usp_GetTableColumns.sql"

# Download the file using Invoke-WebRequest with authentication headers
Invoke-WebRequest -Uri $bitbucketUrl -OutFile $localPath -Headers @{ Authorization = "Basic $base64AuthInfo" }

# Check if the file was downloaded successfully
if (Test-Path $localPath) {
Write-Host "File downloaded successfully to: $localPath"
} else {
Write-Host "Failed to download the file."


Screenshot 2024-02-27 134905.png

1 answer

0 votes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2024

Hi Shravan,

May I know what the $password variable is referring to? We no longer support username/password authentication, so you will need to use App Password for authentication if you are not already doing so.


- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events