powershell authentication to Bamboo error
<p>I am having a problem updating the release label to show if it is broken or Approved etc.  I have got this working through postman so I know that the problem is not through that.  I am using basic authentication with my username and password being entered and trying to get access to the uri using them details but for the powershell it is not working.  It works fine with Postman so it's not the credentials.  Here is what I am doing:</p>

<pre><code>$user = Read-Host -Prompt "Enter Bamboo Username"
$pass =  Read-Host -Prompt "Enter password" -AsSecureString
$secpass = ConvertTo-SecureString $user -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($pass,$secpass)

$baseuri = "http://bamboo.uk.myNetwork.net/rest/api/latest/deploy/version/VersionNumber/status/Approved"

$Headers = @{
'X-Atlassian-Token' = 'nochecK'
};

$json = "application/json"
Invoke-RestMethod -Uri $baseuri -Method Post -Credential $credential -Headers $Headers -ContentType $json 
</code></pre>

<p>This is not working and I am getting the 401client must be authenticated to access this resource.  I have also tried all of the following ways to authenticate the user but none have worked:</p>

<pre><code>&lt;#
$encoded = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($user+":"+$pass))
$EncodedUsernamePassword = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($('{0}:{1}' -f $Credential.UserName, $Credential.GetNetworkCredential().Password)))
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
#&gt;
</code></pre>

<p>Postman with return the following details:</p>

<pre><code>{
  "id": theID,
  "userName": "myUserName",
  "displayName": "myName",
  "creationDate": 1481536833693,
  "versionState": "APPROVED"
}
</code></pre>

<p>This shows that the uri with basic authentication and adding the X-Atlassian-Token: nocheck works but for the powershell I am getting Authentication Errors why is this? </p>