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 = "MyId@MyPlace.com"
$password = "MyPwd"
$csSource = "https://bitbucket.org/MyCompany/MyRepo/SomeSubFolder/SoDeeperSubFolder/MyFile.html"
$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
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
We have also tried this variation:
$username = "MyId@MyPlace.com"
$password = "MyPwd"
$csSource = "https://bitbucket.org/MyCompany/MyRepo/SomeSubFolder/SoDeeperSubFolder"
$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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.