It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

HOWTO - Get past Bitbucket error from PowerShell GET call.

Please help us get past a Bitbuckt error.
We are trying to use PowerShell to get individual files from our Bitbucket repository with the following script:

$username = ""
$password = "MyPwd"
$csSource = ""
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$response = Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Uri $csSource -Method Get

When we run this, we get this error:

Invoke-RestMethod : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:13
+ $response = Invoke-RestMethod -Headers @{Authorization=("Basic {0}" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

We have also tried this variation:

$username = ""
$password = "MyPwd"
$csSource = ""
$credential = New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))
$destination = "C:\MyFolder\MySubFolder\MyFile.CHK.html"
$response = Invoke-WebRequest $csSource -Credential $credential -OutFile (Join-Path -Path $destination -ChildPath "MyFile.html")

And we get the same error.

1 answer

I added the following logic and it gets past the error:


[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


I'm very disappointed that no one helped with this.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Continuous Delivery

Our Atlassian Partners continue to support their customers during coronavirus pandemic

Across the world, governments and healthcare authorities are demonstrating the power of collaboration to find solutions to the COVID-19 pandemic, to protect our communities, and to get things back to...

663 views 0 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you